@ -111,6 +111,22 @@
(catch js/Error err (js/console.log (ex-cause err)))))
(catch js/Error err (js/console.log (ex-cause err)))))
channel)
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
(defn delete-article
"Delete an article and return the id via channel. It gets and returns the same channel."
"Delete an article and return the id via channel. It gets and returns the same channel."
[client id channel]
[client id channel]