Is it possible to bulk update using array of values
See original GitHub issueAs I understand the doc, the model update function can only be used with a single object of values. This is usefull to bulk update multiple rows with the same values.
My question is: is it possible to update multiple rows with different values by passing an array of values containing the id or a unique key to match rows with new values?
var data = [{ id: 1, field1: "foo" }, { id: 2, field1: "bar" }];
Model.update(data, {fields: ['field1']});
Issue Analytics
- State:
- Created 8 years ago
- Reactions:48
- Comments:51 (18 by maintainers)
Top Results From Across the Web
How to make bulk update with arrays in PostgreSQL?
You can unnest them in a subquery: UPDATE services s SET name = x.name, active = x.active, description = x.description FROM (SELECT ...
Read more >$pull — MongoDB Manual
The $pull operator removes from an existing array all instances of a value or ... After the update operation, the document only has...
Read more >Bulk update array / mapping in solidity by a call
You can also use "just-in-time" computations to increment/add/apply function to elements when needed. You can make it self-serve so the cost of ...
Read more >Bulk API | Elasticsearch Guide [8.5] | Elastic
Routingedit. Each bulk item can include the routing value using the routing field. It automatically follows the behavior of the index / delete...
Read more >Retrieving and Modifying Values from Result Sets (The Java ...
You cannot update a default ResultSet object, and you can only move its cursor forward. However, you can create ResultSet objects that can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Not possible with Sequelize, or with SQL afaik. You’ll have to implement a custom function, shouldn’t be too hard, just loop and call update 😃
@mickhansen Thanks. I implemented this using Promise.all. I hoped I will be able to do this with one call … Thank you