diff --git a/src/main/blog/db.cljs b/src/main/blog/db.cljs index 941cda3..038a69c 100644 --- a/src/main/blog/db.cljs +++ b/src/main/blog/db.cljs @@ -45,3 +45,18 @@ (catch js/Error err (js/console.log (ex-cause err))))) channel) +(defn insert-article + "Insert an article and return the id via channel. It gets and returns the same channel." + [client title content channel] + (go + (try + (let [res (js [title content])))] + (>! channel (-> (.-rows res) + (js->clj :keywordize-keys true) + (first) + (:id)))) + (catch js/Error err (js/console.log (ex-cause err))))) + channel) +