kit-clj / kit

Lightweight, modular framework for scalable web development in Clojure
https://kit-clj.github.io/
MIT License
476 stars 44 forks source link

how to hot reload sql functions #106

Closed vinurs closed 1 year ago

vinurs commented 1 year ago

when develop, i add a new function in the sql file

-- :name get-user-by-id :? :1
-- :doc returns a user object by id, or nil if not present
SELECT *
FROM user_profile
WHERE id = :id;

then, how can i hot reload the sql file, and exec the function?

yogthos commented 1 year ago

running (integrant.repl/reset) should do the trick

vinurs commented 1 year ago

everytime when i add a new sql function , i should re-run (def query-fn (:db.sql/query-fn state/system))

yogthos commented 1 year ago

It would be better to use a (defn query-fn [] (:db.sql/query-fn state/system)), this way it'll grab the fresh state of the system when it's called.

vinurs commented 1 year ago

Yes, that solves this problem,thanks