Add a function to get an article by id.
This commit is contained in:
+13
-2
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user