Mongoose 在 4.0 版本之前,验证器不支持update()
、findByIDAndUpdate()
、findOneAndUpdate()
, 但可以支持实例方法 document.save()
。所以可以先找到该条数据,然后调用save()
方法来实现:
Model.findOne({
_id: modelId}, (err, model) => {
model.name = 'newName'
model.
Mongoose 在 4.0 版本之前,验证器不支持update()
、findByIDAndUpdate()
、findOneAndUpdate()
, 但可以支持实例方法 document.save()
。所以可以先找到该条数据,然后调用save()
方法来实现:
Model.findOne({
_id: modelId}, (err, model) => {
model.name = 'newName'
model.