I'm trying to update the values of each item which has a different ID and cost:
await prisma.item.updateMany({
data: [
Object.entries(prices).map(([key, value]) => ({
where: {
id: key
},
data: {
cost: value.cost
}
}))
]
});
However, I'm getting the following error:
Argument `data`: Invalid value provided. Expected ItemUpdateManyMutationInput or ItemUncheckedUpdateManyInput, provided ((Object, Object, Object, Object, Object))
I know that this will work:
for (const [key, value] of Object.entries(prices)) {
await prisma.item.update({
where: {
id: key
},
data: {
cost: value.cost
}
});
}```
But this isn't great for performance, the amount of queries, overhead, etc.
You can try to optimize the whole thing in a