|
|
@ -27,7 +27,18 @@
|
|
|
|
(try
|
|
|
|
(try
|
|
|
|
(let [res (<p! (. client query "select * from articles"))]
|
|
|
|
(let [res (<p! (. client query "select * from articles"))]
|
|
|
|
(>! channel (.-rows res)))
|
|
|
|
(>! 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)
|
|
|
|
channel)
|
|
|
|
|
|
|
|
|
|
|
|