© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
22 replies
DiamondDragon

Missing nested where clause

If you see here i'm missing the ability to do a where filter on the nested
rawDetails
rawDetails
table

The docs say you can do so

await db.query.posts.findMany({
  where: (posts, { eq }) => (eq(posts.id, 1)),
  with: {
    comments: {
      where: (comments, { lt }) => lt(comments.createdAt, new Date()),
    },
  },
});
await db.query.posts.findMany({
  where: (posts, { eq }) => (eq(posts.id, 1)),
  with: {
    comments: {
      where: (comments, { lt }) => lt(comments.createdAt, new Date()),
    },
  },
});

My relations below

export const rawCardsRelations = relations(rawCards, ({ one }) => ({
    rawDetails: one(rawDetails),
}))

export const rawDetailsRelations = relations(rawDetails, ({ one }) => ({
    rawCards: one(rawCards, {
        fields: [rawDetails.rawCardsId],
        references: [rawCards.id],
    }),
}))
export const rawCardsRelations = relations(rawCards, ({ one }) => ({
    rawDetails: one(rawDetails),
}))

export const rawDetailsRelations = relations(rawDetails, ({ one }) => ({
    rawCards: one(rawCards, {
        fields: [rawDetails.rawCardsId],
        references: [rawCards.id],
    }),
}))
image.png
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

Dynamic where clause
Drizzle TeamDTDrizzle Team / help
3y ago
Nested where clauses in relational queries
Drizzle TeamDTDrizzle Team / help
3y ago
Missing 'with' clause additional operators (where, limit, offset, etc)
Drizzle TeamDTDrizzle Team / help
3y ago
[Beginner] complex "where" clause
Drizzle TeamDTDrizzle Team / help
3y ago