I have looked everywhere, and I have not found an easy to understand method of updating a sequelize array, like this with a normal string:
db.User.update({name:req.body.name},{where : {username:req.body.username}}).then(function(user) {
res.json(user);
})
Sequelize doesn't support bulk updates using an array, see https://github.com/sequelize/sequelize/issues/4501
You have to implement a custom function. Here is a basic example to give you an idea :
var promises = [];
userArray.forEach(function(user){
promises.push(db.User.update({name:user.name},{where : {username:user.username}});
});
Promise.all(promises).then(function(){
// success
}, function(err){
// error
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With