multiple updates

17 views
Skip to first unread message

Gary Rusher

unread,
Jan 16, 2018, 9:20:04 AM1/16/18
to Mongoose Node.JS ODM
Hi,

I am wanting to know what the best solution would be for the following.

my endpoint receives an array of documents. I determine they already exist in the db so they need updated.

how can i efficiently update these records?

currently i loop over the array and call schema.update

is there an equivalent schema.updateMany?

Thanks
Gary

Виктор Сергеевич

unread,
Jan 17, 2018, 1:55:23 PM1/17/18
to Mongoose Node.JS ODM


вторник, 16 января 2018 г., 16:20:04 UTC+2 пользователь Gary Rusher написал:
MyModel.update({ name: 'Tobi' }, { ferret: true }, { multi: true }, function (err, raw) { if (err) return handleError(err); console.log('The raw response from Mongo was ', raw); 
}); 
Reply all
Reply to author
Forward
0 new messages