如何在Mongoose模型钩子中自动设置“updatedBy”
假设我们有一个Mongoose模式钩子,如下所示:
someSchema.pre('save', function(next){ this.updatedBy = // assign to the logged in user <<<< this.updatedAt = new Date(); next(); });
我怎样才能将login的用户信息传递给这个钩子?
似乎很难做到,这是默认的方式。
假设我们有一个Mongoose模式钩子,如下所示:
someSchema.pre('save', function(next){ this.updatedBy = // assign to the logged in user <<<< this.updatedAt = new Date(); next(); });
我怎样才能将login的用户信息传递给这个钩子?
似乎很难做到,这是默认的方式。