3

After update model I want to insert new document in activity collection

MySchema.post('update', function(doc, next) {
    // here i want to access req.user (current logged In user)
    ActivityLog.create({
    collectionType: 'MySchema'
    action: 'updated',
    loggedBy: req.user
}).then(function(activity) {
    return next();
});
 });

ActivityLog is Activity schema

Azeem Malik
  • 490
  • 3
  • 16
  • This is basically a duplicate of [this question](http://stackoverflow.com/questions/31331078/mongoose-pass-req-object-to-middleware), which doesn't have a valid answer because AFAIK there isn't a solution that isn't also incredibly hacky. – robertklep Jul 14 '16 at 07:42

0 Answers0