(. client query "CREATE TABLE IF NOT EXISTS articles (id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, content TEXT NOT NULL, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP);"))
(defn get-articles
"Reads all articles and returns via channel. It gets and returns the same channel."
"Insert the about article if not exist and return the id via channel. It gets and returns the same channel."
[client]
(go
(let [channel (chan)]
(try
(let [about (<! (get-about client channel))]
(if (= about [])
(insert-about client channel))
false)
(catch js/Error err
(do (js/console.log (ex-cause err))
true))))))
(defn update-about
"Update the about 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 query "CREATE TABLE IF NOT EXISTS articles (id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, content TEXT NOT NULL, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP);")
(. client query "CREATE TABLE IF NOT EXISTS about (id SERIAL PRIMARY KEY, content TEXT NOT NULL, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP);")