mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-27 03:07:26 +01:00
database: Add pagination and searching
This also unifies the method names.
This commit is contained in:
parent
1c64d56346
commit
da47a01a25
2 changed files with 113 additions and 10 deletions
|
|
@ -43,13 +43,22 @@ CREATE TABLE performances (
|
|||
);
|
||||
|
||||
allPersons:
|
||||
SELECT * FROM persons ORDER BY last_name;
|
||||
SELECT * FROM persons ORDER BY last_name, first_name
|
||||
LIMIT :limit OFFSET :offset;
|
||||
|
||||
searchPersons:
|
||||
SELECT * FROM persons WHERE last_name LIKE :search
|
||||
ORDER BY last_name, first_name LIMIT :limit OFFSET :offset;
|
||||
|
||||
personById:
|
||||
SELECT * FROM persons WHERE id = :id LIMIT 1;
|
||||
|
||||
allInstruments:
|
||||
SELECT * FROM instruments ORDER BY name;
|
||||
SELECT * FROM instruments ORDER BY name LIMIT :limit OFFSET :offset;
|
||||
|
||||
searchInstruments:
|
||||
SELECT * FROM instruments WHERE name LIKE :search ORDER BY name
|
||||
LIMIT :limit OFFSET :offset;
|
||||
|
||||
instrumentById:
|
||||
SELECT * FROM instruments WHERE id = :id LIMIT 1;
|
||||
|
|
@ -60,10 +69,15 @@ SELECT * FROM works WHERE id = :id LIMIT 1;
|
|||
workParts:
|
||||
SELECT * FROM works WHERE part_of = :id ORDER BY part_index;
|
||||
|
||||
-- TODO: Maybe optimize.
|
||||
worksByComposer:
|
||||
SELECT DISTINCT A.* FROM works A LEFT JOIN works B ON A.id = B.part_of
|
||||
WHERE A.part_of IS NULL AND A.composer = :id OR B.composer = :id;
|
||||
WHERE (A.part_of IS NULL AND A.composer = :id) OR B.composer = :id
|
||||
ORDER BY A.title LIMIT :limit OFFSET :offset;
|
||||
|
||||
searchWorksByComposer:
|
||||
SELECT DISTINCT A.* FROM works A LEFT JOIN works B ON A.id = B.part_of
|
||||
WHERE ((A.part_of IS NULL AND A.composer = :id) OR B.composer = :id)
|
||||
AND A.title LIKE :search ORDER BY A.title LIMIT :limit OFFSET :offset;
|
||||
|
||||
composersByWork:
|
||||
SELECT DISTINCT persons.* FROM persons
|
||||
|
|
@ -76,7 +90,11 @@ SELECT instruments.* FROM instrumentations
|
|||
WHERE instrumentations.work = :workId;
|
||||
|
||||
allEnsembles:
|
||||
SELECT * FROM ensembles ORDER BY name;
|
||||
SELECT * FROM ensembles ORDER BY name LIMIT :limit OFFSET :offset;
|
||||
|
||||
searchEnsembles:
|
||||
SELECT * FROM ensembles WHERE name LIKE :search ORDER BY name
|
||||
LIMIT :limit OFFSET :offset;
|
||||
|
||||
ensembleById:
|
||||
SELECT * FROM ensembles WHERE id = :id LIMIT 1;
|
||||
|
|
@ -85,7 +103,8 @@ recordingById:
|
|||
SELECT * FROM recordings WHERE id = :id;
|
||||
|
||||
recordingsByWork:
|
||||
SELECT * FROM recordings WHERE work = :id;
|
||||
SELECT * FROM recordings WHERE work = :id ORDER BY id
|
||||
LIMIT :limit OFFSET :offset;
|
||||
|
||||
performancesByRecording:
|
||||
SELECT * FROM performances WHERE recording = :id;
|
||||
Loading…
Add table
Add a link
Reference in a new issue