I'm Pretty new doing this kind of tasks in Node. I have a POST method (express) wich recive an array of objects like:
[{F1:'123',F2:'a',F3:'b',F4:'Z'},
{F1:'124',F2:'a',F3:'b',F4:'Z'},
{F1:'125',F2:'a',F3:'b',F4:'Z'},
{F1:'126',F2:'a',F3:'b',F4:'Z'},]
Then, i need do an Update for every object in the array. Im using sequelize :
MODEL.update(
{
att4: art['F4'],
},
{
where:{
att1: {$eq: art['F1']}
}
}).then(function(result)
{
res.status(200).send();
}).catch(function(err)
{
res.status(500).send(err);
})
And this work for 1 object.
But i need the following: WHEN ALL THE UPDATES are processed, then send a response.
I try with
req.body.forEach(function(o)
{
updateO(o)
},this);
and in updateO(o) do the Model.Update , but i don't achieve the needed result.
Sorry for the bad english, hope can understand me and thank's for your help.
via federhico
No comments:
Post a Comment