Prisma where every filter on many-to-many

I think I am being super dumb, but I have a many-to-many relationship of Entry to Campaign. I want to find all entries connected to a given campaign. I thought I could just do
const entries = await ctx.prisma.entry.findMany({
where: {
campaigns: { every: { id: { equals: campaignId } } },
},
});
const entries = await ctx.prisma.entry.findMany({
where: {
campaigns: { every: { id: { equals: campaignId } } },
},
});
but this is returning entries that aren't connected to any campaigns as well 😕 According to the docs this should only return every Entrry that has a Campaign with the given id, or am I wrong? I can solve this by adding some: {} to the filter (to exclude every Entry without a Campaign, but this seems unnecessary to me)
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server