0
我面临着猫鼬更新一个奇怪的问题,我不知道去哪里了搜索...猫鼬更新不会保存在DB
我想更新的文件(我想更新,因为我需要排除验证)从模型方法。这是我的代码:
module.exports.plugin = function(schema){
schema.add({ deletedAt : { type : Date, default: null } });
schema.methods.softDelete = function(done){
this.update({_id: this._id}, {deletedAt: new Date()}, function(err, num, raw){
logger.info(err, 'Number Updated: ' + num);
logger.info(raw);
done(err, num);
});
};
};
的功能是否正确触发,这是记录器的输出:
Number Updated: 1
(ok=true, n=1, updatedExisting=true)
,让我假定一切正常,但后来(在蒙戈直接检查)的字段deletedAt
尚未更新。
有什么建议吗?
在此先感谢
什么模式定义是什么样子?它有'deletedAt'属性吗? – laggingreflex 2015-02-10 14:47:23
是的,这是一个附加到多个模式的插件,但在插件中使用'schema.add({deletedAt:{type:Date,default:null}})定义的deletedAt属性ID;' – teone 2015-02-10 15:01:11