From 528cbf2ef570894aaf919ed3da0d3cd129a2c8e8 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 8 Sep 2026 00:43:46 -0700 Subject: db: Add created_at and updated_at fields in tables --- src/controller/routes.phel | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/controller') 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] -- cgit v1.3-2-g0d8e