How to achieve the same in drizzle ORM ?

SELECT 'TOTAL_COURSES' AS name , COUNT(id) FROM course WHERE deleted_at IS NULL
UNION ALL
SELECT 'PUBLISHED_COURSES' AS name, COUNT(id) FROM course WHERE is_published = true AND deleted_at IS NULL
UNION ALL
SELECT 'COURSE_LEAD' AS name, COUNT(id) FROM lead WHERE type = 'COURSE' AND deleted_at IS NULL
UNION ALL
SELECT 'COURSE_LEAD_PENDING' AS name, COUNT(id) FROM lead WHERE type = 'COURSE' AND deleted_at IS NULL
UNION ALL
SELECT 'TOTAL_JOBS' AS name, count(id) FROM job WHERE deleted_at IS NULL
UNION ALL
SELECT 'PUBLISHED_JOBS' as name, count(id) FROM job WHERE is_published = true AND deleted_at IS NULL
UNION ALL
SELECT 'JOB_LEAD' AS name, COUNT(id) FROM lead WHERE type = 'JOB' AND deleted_at IS NULL
UNION ALL
SELECT 'JOB_LEAD_PENDING' AS name, COUNT(id) FROM lead WHERE type = 'JOB' AND deleted_at IS NULL
SELECT 'TOTAL_COURSES' AS name , COUNT(id) FROM course WHERE deleted_at IS NULL
UNION ALL
SELECT 'PUBLISHED_COURSES' AS name, COUNT(id) FROM course WHERE is_published = true AND deleted_at IS NULL
UNION ALL
SELECT 'COURSE_LEAD' AS name, COUNT(id) FROM lead WHERE type = 'COURSE' AND deleted_at IS NULL
UNION ALL
SELECT 'COURSE_LEAD_PENDING' AS name, COUNT(id) FROM lead WHERE type = 'COURSE' AND deleted_at IS NULL
UNION ALL
SELECT 'TOTAL_JOBS' AS name, count(id) FROM job WHERE deleted_at IS NULL
UNION ALL
SELECT 'PUBLISHED_JOBS' as name, count(id) FROM job WHERE is_published = true AND deleted_at IS NULL
UNION ALL
SELECT 'JOB_LEAD' AS name, COUNT(id) FROM lead WHERE type = 'JOB' AND deleted_at IS NULL
UNION ALL
SELECT 'JOB_LEAD_PENDING' AS name, COUNT(id) FROM lead WHERE type = 'JOB' AND deleted_at IS NULL
can someone tell me how i can achieve such, UNION ALL using drizzle ortm, instead of running the as a raw query ?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server