UNPKG

@brownnrl/tcdc-audit-backend-lib

Version:

Backend library for managing audit trail data

32 lines (31 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuditEvent = exports.AuditEventSchema = void 0; const mongoose_1 = require("mongoose"); // Define the schema exports.AuditEventSchema = new mongoose_1.Schema({ changeType: { type: String, enum: ['updated', 'deleted', 'created', 'user-note'], required: true, }, notes: [{ type: String }], // Notes about the record-level change changes: [ { field: { type: String }, oldValue: { type: mongoose_1.Schema.Types.Mixed }, newValue: { type: mongoose_1.Schema.Types.Mixed }, oldValueType: { type: String }, newValueType: { type: String }, notes: { type: String }, }, ], changedBy: { profileId: { type: String, required: true }, name: { type: String, required: true }, isSystem: { type: Boolean, default: false }, }, timestamp: { type: Date, default: Date.now }, }); // Create the model exports.AuditEvent = (0, mongoose_1.model)('AuditEvent', exports.AuditEventSchema);