返回Clojure中数据库查询的密钥



我对Clojure很陌生,想知道如何在Clojure 中查询数据库时简单地返回值

我定义了一个函数foo,如下所示:

(defn get-foo []
(log/info "Getting foo from the database")
(let [query "select FOO from BAR where FOO = 'test'"
results (jdbc/query (db-connection) [query])]
(log/info "Results: " results)
(log/info "Foo: " (get :foo results)
(log/info "String: " (apply str results))))

我在日志中看到的:

Results: ({:foo test})
Foo: nil
String: {:foo "test"}

我希望能够以某种方式只返回test,而不需要像clob中那样附加值,理想情况下,有点像:(log/info "Foo: " results)将返回:

Foo: test
(log/info "Foo: " (:foo (first results)))

退货:

Foo: test

最新更新