我想从数组中提取一些值并同时尝试更新它.
userSchema.statics.experience = function (id,xper,delet,callback) {
var update = {
$pull:{
'profile.experience' : delet
},
$push: {
'profile.experience': xper
}
};
this.findByIdAndUpdate(id,update,{ 'new': true},function(err,doc) {
if (err) {
callback(err);
} else if(doc){
callback(null,doc);
}
});
};
Run Code Online (Sandbox Code Playgroud)
我得到的错误就像 MongoError: exception: Cannot update 'profile.experience' and 'profile.experience' at the same time
mongodb ×1