I am using Prisma and I have two field values that I want to search on
const requests = [{ id, cid }, { id, cid }, { id, cid }];
I want to search on both fields but for many.
for(request of requests) {
prisma.user.findFirst({
where: {
id: request.id,
cid: request.cid
}
});
}
Basically I want to do the above query but for many pairs at once. How to do that?
You are looking for in
operator.
const requests = [{ id, cid }, { id, cid }, { id, cid }];
const ids = requests.map((request)=>request.id);
const cids = requests.map((request)=>request.cid);
const getUser = await prisma.user.findMany({
where: {
id: { in: ids },
cid: { in: cids }
},
})
Here is a link to in
operator documentation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.