Is there a way to create this query in drizzle?

Hi, I have this query for my mobile app with expo and react native. I need to have a recursive query, but cant seem to find how to create one in drizzle.
WITH RECURSIVE LabelHierarchy AS (
SELECT id, name, parent_id
FROM labels
WHERE id = ${labelId}
UNION ALL
SELECT l.id, l.name, l.parent_id
FROM labels l
INNER JOIN LabelHierarchy lh ON lh.id = l.parent_id
)
SELECT e.id, e.exercise_name
FROM exercises e
INNER JOIN exercise_label el ON e.id = el.exercise_id
INNER JOIN LabelHierarchy lh ON el.label_id = lh.id;
WITH RECURSIVE LabelHierarchy AS (
SELECT id, name, parent_id
FROM labels
WHERE id = ${labelId}
UNION ALL
SELECT l.id, l.name, l.parent_id
FROM labels l
INNER JOIN LabelHierarchy lh ON lh.id = l.parent_id
)
SELECT e.id, e.exercise_name
FROM exercises e
INNER JOIN exercise_label el ON e.id = el.exercise_id
INNER JOIN LabelHierarchy lh ON el.label_id = lh.id;
Please let me know if it is possible to rewrite this with drizzle :) Thanks!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server