Add the delete-article to delete an article by the id.
This commit is contained in:
@@ -60,3 +60,18 @@
|
|||||||
(catch js/Error err (js/console.log (ex-cause err)))))
|
(catch js/Error err (js/console.log (ex-cause err)))))
|
||||||
channel)
|
channel)
|
||||||
|
|
||||||
|
(defn delete-article
|
||||||
|
"Delete an article and return the id via channel. It gets and returns the same channel."
|
||||||
|
[client id channel]
|
||||||
|
(go
|
||||||
|
(try
|
||||||
|
(let [res (<p! (.query client
|
||||||
|
"delete from articles where id = $1 returning id;"
|
||||||
|
(clj->js [id])))]
|
||||||
|
(>! channel (-> (.-rows res)
|
||||||
|
(js->clj :keywordize-keys true)
|
||||||
|
(first)
|
||||||
|
(:id))))
|
||||||
|
(catch js/Error err (js/console.log (ex-cause err)))))
|
||||||
|
channel)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user