having an array with unique names, how can i update the elemets of those names using prisma(in nextjs). I mean something Like:
const arr=['Joe', 'Mark'];
const update=await prisma.user.updateMany({
where: {
name: //What should i put to update both Joe and Mark?
},
data: {
notifications: {push: "Hello"}
}
});
I'm using PSQL and i don't know if it matters.
CodePudding user response:
Try this:
const arr=['Joe', 'Mark'];
const update=await prisma.user.updateMany({
where: {
name: {in: arr}
},
data: {
notifications: {push: "Hello"}
}
});
"in" will check if name matches anything in that array. Here is the list of other filters: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#filter-conditions-and-operators