I am using this library Mongoose Audit Plugin and I have added this snippet in my entity schema:
let AuditLog = require('mongoose-audit')
GiftSchema.virtual('Author').set(function (userEmail) {
this._user = userEmail
})
Middleware code look like this but it's not saving user in auditlog collection.
var updated = _.merge({}, req.body, {
Author: req.decoded.user
})
Any suggestions? I have also used this package but it didn't save any record in DB. mongoose-audit-log
req.body = _.merge({}, req.body, {
Author: req.decoded.user
})
Resolved. I just merged the body in request instead of updated variable