DT
Drizzle Team•14mo ago
midi

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
Type '{ where: SQL<unknown>; }' is not assignable to type 'true | { columns ?: ...
Object literal may only specify known properties, and 'where' does not exist in type '{ columns ?: .....
Type '{ where: SQL<unknown>; }' is not assignable to type 'true | { columns ?: ...
Object literal may only specify known properties, and 'where' does not exist in type '{ columns ?: .....
How do I add more filters to a relational query?
No description
3 Replies
funabab
funabab•14mo ago
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 }) => (...
midi
midiOP•14mo ago
What are the recommended alternative methods 😅 ?
dromzeh
dromzeh•14mo ago
You can use the CRUD api or can apply your own filtering after you fetch data
Want results from more Discord servers?
Add your server