changes
This commit is contained in:
1 parent
a99af426db
commit
8886aa8640
91 files changed
+2823
-773
No files matched your search
@@ -0,0 +1,29 @@
|
||||
/** Shared SELECT fragment: course row + JSON arrays of categories/tags. */
|
||||
export const COURSE_WITH_TAXONOMY_SELECT = `
|
||||
SELECT c.*,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT json_agg(
|
||||
json_build_object('id', cat.id, 'slug', cat.slug, 'label', cat.label)
|
||||
ORDER BY cat.sort_order ASC, cat.label ASC
|
||||
)
|
||||
FROM course_category_links l
|
||||
JOIN course_categories cat ON cat.id = l.category_id
|
||||
WHERE l.course_id = c.id
|
||||
),
|
||||
'[]'::json
|
||||
) AS categories,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT json_agg(
|
||||
json_build_object('id', t.id, 'slug', t.slug, 'label', t.label)
|
||||
ORDER BY t.sort_order ASC, t.label ASC
|
||||
)
|
||||
FROM course_tag_links l
|
||||
JOIN course_tags t ON t.id = l.tag_id
|
||||
WHERE l.course_id = c.id
|
||||
),
|
||||
'[]'::json
|
||||
) AS tags
|
||||
FROM courses c
|
||||
`;
|
||||
Reference in new issue
Block a user