|
|
@ -45,3 +45,18 @@
|
|
|
|
(catch js/Error err (js/console.log (ex-cause err)))))
|
|
|
|
(catch js/Error err (js/console.log (ex-cause err)))))
|
|
|
|
channel)
|
|
|
|
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 (<p! (.query client
|
|
|
|
|
|
|
|
"insert into articles(title, content) values($1, $2) returning id;"
|
|
|
|
|
|
|
|
(clj->js [title content])))]
|
|
|
|
|
|
|
|
(>! channel (-> (.-rows res)
|
|
|
|
|
|
|
|
(js->clj :keywordize-keys true)
|
|
|
|
|
|
|
|
(first)
|
|
|
|
|
|
|
|
(:id))))
|
|
|
|
|
|
|
|
(catch js/Error err (js/console.log (ex-cause err)))))
|
|
|
|
|
|
|
|
channel)
|
|
|
|
|
|
|
|
|
|
|
|