© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
8 replies
Nxia618

Nested where filter, how to not include empty

The following almost works
const query = db.query.productionItem.findMany({
  with: {
    itemStages: {
      where: eq(itemStage.crew_id, input.crew_id),
    },
  },
});
const query = db.query.productionItem.findMany({
  with: {
    itemStages: {
      where: eq(itemStage.crew_id, input.crew_id),
    },
  },
});

I get only those productionItems with itemStage of particular crew_id, but I also get those with no itemStage's so query result has
itemStages: []
itemStages: []
. How do I only include if crew_id equal and productionItem has itemStage
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

Filter (Where)
Drizzle TeamDTDrizzle Team / help
3y ago
Filter Empty Relations out
Drizzle TeamDTDrizzle Team / help
12mo ago
How to filter length in where for postgres?
Drizzle TeamDTDrizzle Team / help
3y ago
where filter returning typescript error when nested within a with
Drizzle TeamDTDrizzle Team / help
3y ago