Working with SQL in Clojure/Luminus/Composure -


1) have luminus app. want execute multiple db requests within single db connection, meaning, without having open connection second time. have this:

(defn page1 [id]   (layout/render "page1.html"     (my-var1 (db/get-single-article {:id (integer/parseint id)})))) 

i want execute else, say, db/get-something-else, within same db connection db/get-single-article executed. how?

2) in resources/sql/queries.sql have this:

-- :name get-single-article :? :1 -- :doc retrieve article given id. select * article id = :id 

how can add 1 more query it'll execute within db/get-single-article call , return different result set? this:

-- :name get-single-article :? :1 -- :doc retrieve article given id. select * article id = :id  select * another_table ... 

how can navigate them when calling db/get-single-article then?

go ahead , define second query in sql file:

-- :name get-something-else :? :* select * another_table ... 

then assign query results both queries this:

(defn page1 [id]   (layout/render "page1.html"     {:my-var1 (db/get-single-article {:id (integer/parseint id)})      :my-var2 (db/get-something-else)})) 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -