I'm using nodejs with mongodb and need to log users actions (who does what ).
To do so, I'm using pre middleware and log4js to write in file, it's something like this :
var userSchema = new Schema(..);
userSchema.pre('save', function(next) {
log.TRACE(req.user.id ...);
next();
});
All I need now is to pass a param(req.user.id) from user.save() or user.update() to my pre middlware in order to use it in my log file but don't know how to do that.