Dev__
07/20/2021, 9:21 PMmodel Buyer {
id
buyersToBuyerGroups BuyersToBuyerGroups[]
}
model BuyerGroup {
id
buyersToBuyerGroups BuyersToBuyerGroups[]
}
model BuyersToBuyerGroups {
buyerId
buyerGroupId
buyerGroup BuyerGroup @relation(fields: [buyerGroupId], onDelete: Cascade, references: [id])
buyer Buyer @relation(fields: [buyerId], onDelete: Cascade, references: [id])
}
so lets say there is two records inside the BuyersToBuyerGroups
buyerId buyerGroupId
1 32
1 12
so what I want with this query is I want to fetch all buyer groups where buyerId
is equal to x
prisma.buyerGroup.findMany({
where: {
buyersToBuyerGroups = {
every: {
buyerId: 1
}
};
}
})
I expect it to return only 2 buyerGroups
because of the where
but instead it returns me all rows expect those 2. am I misunderstanding every
or is this suppose to happen?
when i use some
it works as expected, I only get back 2 records...Ryan
07/22/2021, 5:44 AMsome
. Some matches one or more records and returns at least those. While every tries to match all and it won’t return anything even if one of them doesn’t match.
This example from the docs makes it clear: https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#relation-filters