summaryrefslogtreecommitdiffstats
path: root/src/controller
diff options
context:
space:
mode:
authorGravatar Tom Willemse2026-09-08 00:43:46 -0700
committerGravatar Tom Willemse2026-09-08 00:43:46 -0700
commit528cbf2ef570894aaf919ed3da0d3cd129a2c8e8 (patch)
treed7a7a0d3a18efa4f5a1fc6a3e7f654cc49b72f1d /src/controller
parent1fd54b7aa0449bd16b484f289da7b5264161f967 (diff)
downloadlezer-528cbf2ef570894aaf919ed3da0d3cd129a2c8e8.tar.gz
lezer-528cbf2ef570894aaf919ed3da0d3cd129a2c8e8.zip
db: Add created_at and updated_at fields in tables
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]