Reputation: 43511
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);
});
});
When I do the .save
, it doesn't save, but it also doesn't error. What gives?
Upvotes: 2
Views: 227
Reputation: 84
try something like this
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;
}
);
}
});
Upvotes: 1