refactor(db): Migrate some more category queries to SQLDelight

This commit is contained in:
Ahmad Ansori Palembani 2024-11-29 11:28:38 +07:00
parent 9c40aadca2
commit ca41e02fe1
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
12 changed files with 187 additions and 21 deletions

View file

@ -15,3 +15,22 @@ findAllByMangaId:
SELECT categories.* FROM categories
JOIN mangas_categories ON categories._id = mangas_categories.category_id
WHERE mangas_categories.manga_id = :mangaId;
insert:
INSERT INTO categories (name, sort, flags, manga_order)
VALUES (:name, :sort, :flags, :mangaOrder);
selectLastInsertedRowId:
SELECT last_insert_rowid();
update:
UPDATE categories SET
name = coalesce(:name, name),
sort = coalesce(:sort, sort),
flags = coalesce(:flags, flags),
manga_order = coalesce(:mangaOrder, manga_order)
WHERE _id = :id;
delete:
DELETE FROM categories
WHERE _id = :id;