summaryrefslogtreecommitdiffstats
path: root/src/controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller')
-rw-r--r--src/controller/routes.phel11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/controller/routes.phel b/src/controller/routes.phel
index b6335ca..2e537db 100644
--- a/src/controller/routes.phel
+++ b/src/controller/routes.phel
@@ -24,12 +24,17 @@
subtitle (get-in request [:parsed-body "subtitle"])
authors (str/split (get-in request [:parsed-body "author"]) #",")]
(pdo/with-transaction conn
- (let [book-id (pdo/insert conn :books {:title title
- :subtitle subtitle})]
+ (let [time (php/time)
+ book-id (pdo/insert conn :books {:title title
+ :subtitle subtitle
+ :created_at time
+ :updated_at time})]
(for [a :in authors]
(pdo/insert conn :authors_books {:book_id book-id
:author_id (or (pdo/fetch-column (pdo/query conn "select id from authors where name = :name" {:name a}))
- (pdo/insert conn :authors {:name a}))})))))
+ (pdo/insert conn :authors {:name a
+ :created_at time
+ :updated_at time}))})))))
(h/response-from-map {:status 301 :headers {:location "/"}}))
(defn author-view-handler [req]