mongoose保存不起来从findOne一些奇怪的原因
Gig.findOne({ _id: data.gig }).populate(populate).exec(function(err, gig) { gig.lastChatTime = Date.now(); gig.lastChatBy = params.by; gig.meta.chats += 1; return gig.save(function(err) { return console.log(err); }); });
当我做.save
,它不保存,但也不会出错。 是什么赋予了?
尝试这样的事情
Gig.findOne({ _id: data.gig }).populate(populate).exec(function(err, gig) { if(gig){ Gig.update({_id: gig._id}, { lastChatTime : Date.now(), lastChatBy : params.by, meta.chats : meta.chats+ 1 }, { runValidators: true },function(err){ if(err){ throw err; } ); } });
- 在Mongoskin分页(跳过+限制)
- MongoDB(Mongoose)如何使用$ elemMatch返回所有文档字段
- Mongooseasynchronous调用内循环与asynchronous库
- 为什么Meteor.users.findOne({username:“test”})返回一个对象,但用具有相同值的variablesreplace“test”会返回undefined
- Loopback.js – 将基础“用户”模型扩展为“用户”,而不需要MongoDB创build“用户”和“用户”集合
- 404骨干错误.save()
- Mongodb,mongoose – dynamic设置TTL时间
- Mongoose:我如何更新与数组中的一个项目匹配的数组值?
- 在Mongoose更新查询期间,JavaScript对象元素缺失