Add a function to get an article by id.

main
KKlochko 1 year ago
parent c7223f0a00
commit 1ad0610f19

@ -27,7 +27,18 @@
(try
(let [res (<p! (. client query "select * from articles"))]
(>! channel (.-rows res)))
(catch js/Error err (js/console.log (ex-cause err))))
)
(catch js/Error err (js/console.log (ex-cause err)))))
channel)
(defn get-article
"Reads an article with the id and returns via channel. It gets and returns the same channel. Empty collection if not found."
[client id channel]
(go
(try
(let [res (<p! (.query client
"select * from articles where id=$1"
(cljs.core/clj->js [id])))]
(>! channel (.-rows res)))
(catch js/Error err (js/console.log (ex-cause err)))))
channel)

Loading…
Cancel
Save