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!
3 Replies
Angelelz
Angelelz•16mo ago
Mr.T - Mitosis
Mr.T - MitosisOP•16mo ago
Ow thank you, around that's a shame though, but I can always make them as "many" and get the first index I guess :/ not ideal though.. Do you have other solution in mind?
Angelelz
Angelelz•16mo ago
You can always fall back to the crud API and just do a join
Want results from more Discord servers?
Add your server