unionAll gives TypeError: leftSelect.getSelectedFields is not a function
I'm trying to query 2 collections in the same query as the amount of collections might grow over time that I will check against I would want a scalable way and also use drizzles built in features, so I tryed this:
Note I'm using Payload CMS, so I don't have access to the schema files directly, actually got no clue if its db.schema or db.tables I should use.
Running these queries separately works great, just when I add unionAll I get:
Code:
This is the documentation that I looked at which I feel like I replicated:
https://orm.drizzle.team/docs/set-operations#union-all
Any help is super appreciated!
Set Operations - Drizzle ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
1 Reply
unionAll
accepts queries that you want to unite.
I would create the query array outside of the unionAll
call trying to let TS infer the types for you.
Even then, I'm not sure this approach will satisfy the compiler