harris_paint / src /models /AuditLog.js
aliroohan179's picture
Upload 58 files
10821c7 verified
Raw
History Blame Contribute Delete
633 Bytes
const mongoose = require('mongoose');
const auditLogSchema = new mongoose.Schema({
action: { type: String, required: true },
actor: { type: mongoose.Schema.Types.ObjectId, ref: 'Admin', required: true },
targetType: { type: String },
targetId: { type: mongoose.Schema.Types.ObjectId },
details: { type: mongoose.Schema.Types.Mixed },
ipAddress: { type: String },
timestamp: { type: Date, default: Date.now },
});
auditLogSchema.index({ actor: 1, timestamp: -1 });
auditLogSchema.index({ targetType: 1, targetId: 1 });
auditLogSchema.index({ action: 1 });
module.exports = mongoose.model('AuditLog', auditLogSchema);