search for a book with a single value
This commit is contained in:
@@ -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
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
insert into books(name, description, editor, authors, year, keywords, path)
|
||||
values (?,?,?,?,?,?,?)
|
||||
@@ -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(?)
|
||||
|
||||
Reference in New Issue
Block a user