Is there a way to use `updateMany` to update multi...
# orm-help
r
Is there a way to use
updateMany
to update multiple different records at once? For example I have an array
[{ id: 1, name: 'Foo' }, { id: 2, name: 'Bar' }]
that I want to change to
[{ id: 1, name: 'FOO' }, { id: 2, name: 'BAR' }]
. Or is
updateMany
only used to update records to all have the same given value?
m
That is not possible with
updateMany
.
updateMany
is for updating many records with the same data. For your use case you would need to loop through your array and use
update
in each iteration.
r
Thanks, I ended up just creating an array of updates and using
$transaction