© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•6mo ago
k

Filter items by field on relation using query format

Lets say we have table posts that is many to one to a profile:

const posts = await db.query.posts.findMany({
with: {
profile: true,
},
});

I want to be able to get the posts only where the profile relation has subscribed = true, without filtering on the js side

Is there any way to do this with the query (I know I could do select with joins) format, something like:

where: eq(post.profileRelation.subscribed, true)

Thanks for any ideas
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Using Query Syntax to filter by FK's field
Drizzle TeamDTDrizzle Team / help
3y ago
can we filter by a prop on a relation during a query?
Drizzle TeamDTDrizzle Team / help
2y ago
Group related items in relation query
Drizzle TeamDTDrizzle Team / help
2y ago
Ordering by relation in relational query
Drizzle TeamDTDrizzle Team / help
3y ago