Drizzle relational query, filters
I'm trying to add some simple filters to my query, as according to https://orm.drizzle.team/docs/rqb#select-filters
I've tried both
where: eq(users.id, 1)
syntax, and where: (users, { eq }) => eq(users.id, 1),
- both result in
How do I add more filters to a relational query?Drizzle Queries - DrizzleORM
Drizzle ORM | %s
3 Replies
The docs hasn't being updated, filtering by nested relation was removed in v0.28.0
https://github.com/drizzle-team/drizzle-orm/releases/tag/0.28.0
It's quite sad that all recommended alternatives methods are not quite straightforward. Only option that available if you really need it is to use a version prior to 0.28.0
GitHub
Release 0.28.0 · drizzle-team/drizzle-orm
Breaking changes
Removed support for filtering by nested relations
Current example won't work in 0.28.0:
const usersWithPosts = await db.query.users.findMany({
where: (table, { sql }) => (...
What are the recommended alternative methods 😅 ?
You can use the CRUD api or can apply your own filtering after you fetch data