Drizzle TeamDT
Drizzle Team•3y ago
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,
            },
          },
        },
      },
    },
})

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!
Was this page helpful?