Add the delete-article to delete an article by the id.

main
KKlochko 1 year ago
parent 75a3f7737d
commit 72cbb71d55

@ -60,3 +60,18 @@
(catch js/Error err (js/console.log (ex-cause err)))))
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)

Loading…
Cancel
Save