0

Is it possible to update multiple rows with one query? Like in insert i can pass an array of objects and each key refers each column. Is there anything like that for an update query?

I have an array of objects (id, value) and i want to update all the fields that match id from the object with the value from the same object.

Jan Kowalski
  • 203
  • 1
  • 4
  • 12

1 Answers1

-1

There is a way to update it using PostgreSQL query and it was answered here. But it requires some magic and ugly .raw code to use this with knex. So, I'd recommend using multiple update statements in one transaction. And synchronize them using Promise.all([updates]).

coockoo
  • 2,028
  • 16
  • 25