This commit is contained in:
seb
2026-07-31 00:08:50 +02:00
parent 93e52cd513
commit 6bdac7e543
17 changed files with 520 additions and 24 deletions

16
src/sql/category.js Normal file
View File

@@ -0,0 +1,16 @@
export const GET_TREE = `
WITH tree AS (
SELECT id, parent_id, sort
FROM category
WHERE id = @rootId
UNION ALL
SELECT c.id, c.parent_id, c.sort
FROM category c
INNER JOIN tree t ON c.parent_id = t.id
)
SELECT id, parent_id, sort
FROM tree
ORDER BY sort, id
`;