findMany where two element in array
Unanswered
Cuvier’s Dwarf Caiman posted this in #help-forum
Cuvier’s Dwarf CaimanOP
Hi, i have some troubles with a query, in my schema i have a room model where there is a column roomUsers[] that reach the user model, in my query i want to retrieve the rooms where two specific users are found in the roomUsers[] relational array. May this can help you understand my goal :
const room = await prisma.room.findMany({
where: {
roomUsers: {
some: [User1ID, User2ID]
}
}
});
I know that is wrong but it's to clarify.
Hope that someone could help me. Thanks.
const room = await prisma.room.findMany({
where: {
roomUsers: {
some: [User1ID, User2ID]
}
}
});
I know that is wrong but it's to clarify.
Hope that someone could help me. Thanks.
2 Replies
American Crow
I am not using prisma but it should be just a logical AND ? Both conditions must be true
const result = await prisma.post.findMany({
where: {
AND: [
{
content: {
contains: 'Prisma',
},
},
{
published: {
equals: false,
},
},
],
},
})Cuvier’s Dwarf CaimanOP
alright i'm gonna see later, thanks for help