Create a new AuditLogger instance
The Prorm instance
Optionaloptions: AuditLoggerOptions
Optional configuration options
Get the audit model
Log an audit action
The type of action (CREATE, UPDATE, DELETE)
The name of the table
The primary key of the record
OptionaloldValues: Record<string, any>
The previous values (for UPDATE/DELETE)
OptionalnewValues: Record<string, any>
The new values (for CREATE/UPDATE)
Get audit history for a table and optional record
The name of the table
OptionalrecordId: string | number
Optional record ID to filter by
Optionaloptions: { limit?: number; offset?: number; startDate?: Date; endDate?: Date }
Query options
Setup hooks for all models to automatically log changes
This method iterates through all registered models and adds beforeCreate, beforeUpdate, and beforeDestroy hooks
Add audit hooks to a specific model
The model to add hooks to
Check if a model has audit hooks
The model to check
AuditLogger - Provides persistent audit logging for model changes
Example