Add the function to update an article.

main
KKlochko 1 year ago
parent 74f220bcc8
commit 09ce47614a

@ -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 (<p! (.query client
(str "update articles "
"set title = $2,"
"content = $3,"
"created = CURRENT_TIMESTAMP "
"where id = $1;")
(clj->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]

Loading…
Cancel
Save