在Mongoose模型中访问req对象

时间:2016-07-14 07:18:19

标签: javascript node.js express mongoose mongoose-schema

更新模型后,我想在活动集合中插入新文档

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是活动架构

0 个答案:

没有答案