diff options
| author | 2026-08-27 00:11:47 -0700 | |
|---|---|---|
| committer | 2026-08-27 00:11:47 -0700 | |
| commit | 94ef10d1fe4ed27f8442944c25ecc0300c5e5655 (patch) | |
| tree | f587feeab0231fa9c8ecd5252a9fa8f90b6d3094 /src/controller/routes.phel | |
| parent | ba790e23e84c2146e15d3735862dc056f6baef41 (diff) | |
| download | lezer-main.tar.gz lezer-main.zip | |
Diffstat (limited to 'src/controller/routes.phel')
| -rw-r--r-- | src/controller/routes.phel | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/controller/routes.phel b/src/controller/routes.phel index 75d1d5f..726f57b 100644 --- a/src/controller/routes.phel +++ b/src/controller/routes.phel @@ -8,7 +8,7 @@ (:require phel.string :as str)) (def conn (pdo/connect "sqlite:test.db")) -(pdo/exec conn "create table if not exists books (id integer primary key autoincrement, title varchar(255))") +(pdo/exec conn "create table if not exists books (id integer primary key autoincrement, title varchar(255), subtitle varchar(255))") (pdo/exec conn "create table if not exists authors (id integer primary key autoincrement, name varchar(255))") (pdo/exec conn "create table if not exists authors_books (author_id integer, book_id integer)") @@ -25,9 +25,11 @@ (defn book-create-handler [request] (let [title (get-in request [:parsed-body "title"]) + 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})] + (let [book-id (pdo/insert conn :books {:title title + :subtitle subtitle})] (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})) |
