search for a book with a single value

This commit is contained in:
rmanach
2025-01-07 09:29:21 +01:00
parent 1c6b758f0c
commit 42a3181797
12 changed files with 341 additions and 12 deletions
+9
View File
@@ -0,0 +1,9 @@
create table if not exists books (
name text primary key,
description text,
editor text not null,
authors jsonb not null,
year int not null,
keywords jsonb,
path text not null
)
+2
View File
@@ -0,0 +1,2 @@
insert into books(name, description, editor, authors, year, keywords, path)
values (?,?,?,?,?,?,?)
+20
View File
@@ -0,0 +1,20 @@
select
b.*
from
books b
where
lower(b.name) like lower(?)
or lower(b.description) like lower(?)
or lower(b.editor) like lower(?)
or lower(b.year) like lower(?)
union
select
b2.*
from books b2, json_each(b2.authors)
where lower(json_each.value) like lower(?)
union
select
b3.*
from books b3, json_each(b3.keywords)
where lower(json_each.value) like lower(?)