下面是我的代码
var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/test'); var Cat = mongoose.model('Cat', { name: String, age: {type: Number, default: 20}, create: {type: Date, default: Date.now} Cat.findOneAndUpdate({age: 17}, {$set:{name:"Naomi"}},function(err, doc){ if(err){ console.log("Something wrong when updating data!");