Why it's not possible to use `where` here?
I'm trying to make a PoC for drizzle and I'm converting some sequelize to Drizzle, but I don't really have experience with databases to be honest with you.
I can't understand, why using
where
is not possible in this case.
Seems like I don't quite understand how to describe BelongsTo
with Drizzle and that might be a problem.
Can you guys help? Thanks5 Replies
you can't use where with a
one
relation
but if you want to retrive the account of an accountContact, all you need is
and you would use where on findMany to filter by the accountContactThanks for the reply. In sequelize, I’m filtering results like that. So, account has vendorId and I need to filter out data with it. What would be the way to achieve this with drizzle? I can’t change db structure.
well, they've removed it as of 0.28: https://github.com/drizzle-team/drizzle-orm/releases/tag/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 }) => (...
but i think you can work around it in your case if you go from account
Gotcha, so I have to use it other way around and there’s no way to persist the data, like in sequelize was.
Thanks a lot! @aveatrex