Closed vinurs closed 11 months ago
So, what happens with the query-fn
is that it uses bind-connection-map from conman to initialize the queries and snippets, you can see this here https://github.com/kit-clj/kit/blob/master/libs/kit-sql-conman/src/kit/edge/db/sql/conman.clj
and the helper functions come from conman here https://github.com/luminus-framework/conman/blob/78eb55c992b74095bf63a3d67b0c2a27d4d620e7/src/conman/core.clj#L119
thanks for ur help in system.edn i defined a snip-fn
:db.sql/snip-fn
{:conn #ig/ref :db.sql/connection
:options {}
:filenames ["sql/pg/snippets.sql"]}
then
(defmethod ig/init-key :db.sql/snip-fn
[_ {:keys [conn options filename filenames]
:or {options {}}}]
(let [filenames (or filenames [filename])
snips (apply conman/bind-connection-map conn options filenames)]
(fn [snip params]
(conman/snip snips snip params))))
so now can call it as following
(query-fn :snip-query
{:select (snip-fn :select-snip {:cols ["id","nickname"]})
:from (snip-fn :from-snip {:tables ["user_profile"]})
:where (snip-fn :where-snip
{:cond [(snip-fn :cond-snip {:conj "" :cond ["id" "=" 10001]})
(snip-fn :cond-snip {:conj "or" :cond ["id" "=" 10002]})]})})
from https://www.hugsql.org/using-hugsql/composability/snippets
then run the snip-query
but in this framework, how should i do to run
snip-query
?but the
select-snip
from-snip
how to