Add Audit cababilities. First try on deleteOne

This commit is contained in:
George Suntres
2026-04-23 13:19:20 -04:00
parent 49a1d24660
commit f0c0c55e89
11 changed files with 402 additions and 35 deletions

22
audit.go Normal file
View File

@@ -0,0 +1,22 @@
package mongo
type Op string
const (
OpUpdate Op = "update"
OpDelete Op = "delete"
OpInsert Op = "insert"
OpArchive Op = "archive"
OpRestore Op = "restore"
)
type AuditResult struct {
Op Op `bson:"op" json:"op"`
Entity string `bson:"entity" json:"entity"`
Data any `bson:"data" json:"data"`
Before any `bson:"before" json:"before"`
After any `bson:"after" json:"after"`
Context any `bson:"context" json:"context"`
}
type OnAudit func(audit *AuditResult) error