© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
3 replies
Mr.T

Can't filter using 'query' when relation is one to one

Hello, I'm trying to use where filter on this query:
 const qb = db.query.event.findMany({
    with: {
      workoutSession: {
        where: eq(workoutSession.athleteId, userId),
        with: {
          workoutResult: {
            with: {
              workout: true,
            },
          },
        },
      },
    },
})
 const qb = db.query.event.findMany({
    with: {
      workoutSession: {
        where: eq(workoutSession.athleteId, userId),
        with: {
          workoutResult: {
            with: {
              workout: true,
            },
          },
        },
      },
    },
})

And for some reason, where just isn't an option when event <-> workoutSession are a one-to-one relationship
if I create a one-to-many relationship in the schema, then I can safely use where here.
I wonder if that is something normal 🤔 Thanks!
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 items by field on relation using query format
Drizzle TeamDTDrizzle Team / help
6mo ago
Can't seem to $count in multi relation query
Drizzle TeamDTDrizzle Team / help
15mo ago
Cant query with relation using query method
Drizzle TeamDTDrizzle Team / help
2y ago
Count of one-to-many relation in query
Drizzle TeamDTDrizzle Team / help
3y ago