1)我有一个发光的应用程序。我想在一个数据库连接中执行多个数据库请求,也就是说,不必再次打开连接。现在我有了这个:
(defn page1 [id]
(layout/render "page1.html"
(my-var1 (db/get-single-article {:id (Integer/parseInt id)}))))我想在执行db/get-single-article的同一个db连接中执行一些其他的东西,比如db/get- the else。多么?
2)在resources/sql/queries.sql ies.sql中,我有:
-- :name get-single-article :? :1
-- :doc retrieve an article given the id.
SELECT * FROM article
WHERE id = :id如何再添加一个查询,使其在db/get-single-article调用中执行并返回不同的结果集?如下所示:
-- :name get-single-article :? :1
-- :doc retrieve an article given the id.
SELECT * FROM article
WHERE id = :id
select * from another_table
where ...那么,当我调用db/get-single-article时,我该如何导航它们呢?
发布于 2016-05-25 17:58:35
继续在SQL文件中定义第二个查询:
-- :name get-something-else :? :*
select * from another_table where ...然后为两个查询分配查询结果,如下所示:
(defn page1 [id]
(layout/render "page1.html"
{:my-var1 (db/get-single-article {:id (Integer/parseInt id)})
:my-var2 (db/get-something-else)}))https://stackoverflow.com/questions/37431225
复制相似问题