From 72cbb71d554a81811c475eb82a3ab5821f62de2e Mon Sep 17 00:00:00 2001 From: KKlochko Date: Tue, 9 Apr 2024 20:44:54 +0300 Subject: [PATCH] Add the delete-article to delete an article by the id. --- src/main/blog/db.cljs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/blog/db.cljs b/src/main/blog/db.cljs index 038a69c..ed98492 100644 --- a/src/main/blog/db.cljs +++ b/src/main/blog/db.cljs @@ -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 (js [id])))] + (>! channel (-> (.-rows res) + (js->clj :keywordize-keys true) + (first) + (:id)))) + (catch js/Error err (js/console.log (ex-cause err))))) + channel) +