mongodb - can findOneAndUpdate trigger schema post update/save? -


i stuck socket io problem emit changes. wondering there way trigger scheme.post update or save. @ moment scheme.post save doesn't work findoneandupdate, please out been stuck hrs... appreciated.

  project.schema.post('update', function (doc) {     onsave(socket, doc);   });   project.schema.post('save', function (doc) {     onsave(socket, doc);   }); 

where udate

project.findoneandupdate(     {        _id: req.body._id      },     { $set:        { 'watchers' : req.body.watchers }     },     function(err, data) {       return res.json(200, data)     }   ); 

that issue covered in detail here. i'll let read through why solution maintainers added special post hook it:

 project.schema.post('findoneandupdate', function (doc) {    onsave(socket, doc);  }); 

note: not sure if doc provided though.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -