I have a question on how to do CRUD operation Update on Mongoose.
I can update 1 record by doing this:
EmpModel.findOne()
.where('empId')
.lt(101)
.exec()
.then((emp) => {
emp.age = 67;
emp.save();
});
But I cannot update many record at the same time by doing this (error):
EmpModel.find()
.where('empId')
.lt(101)
.exec()
.then((emp) => {
emp.age = 67;
emp.save();
});
The error is:
TypeError: emp.save is not a function
Could you guys explain me why I cannot update many records at the same time?
Thanks a lot.