From 09ce47614a1acf3a24db11bdef896e309a26d435 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Mon, 15 Apr 2024 18:27:43 +0300 Subject: [PATCH] Add the function to update an article. --- src/main/blog/db.cljs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/blog/db.cljs b/src/main/blog/db.cljs index 2a63804..c58b0bb 100644 --- a/src/main/blog/db.cljs +++ b/src/main/blog/db.cljs @@ -111,6 +111,22 @@ (catch js/Error err (js/console.log (ex-cause err))))) channel) +(defn update-article + "Update an article and return the id via channel. The timestamp for created will be updated to current timestamp. It gets and returns the same channel." + [client {:keys [id title content]} channel] + (go + (try + (let [res (js [id title content])))] + (>! channel (-> id))) + (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]