@dynamatix/cat-shared 0.0.73 → 0.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -70,7 +70,7 @@ function applyAuditMiddleware(schema, collectionName) {
|
|
|
70
70
|
|
|
71
71
|
// Handle update audits
|
|
72
72
|
schema.post(['findOneAndUpdate', 'findByIdAndUpdate'], async function (result) {
|
|
73
|
-
if (!result
|
|
73
|
+
if (!result) return;
|
|
74
74
|
|
|
75
75
|
const auditConfig = await AuditConfigModel.findOne({ collectionName });
|
|
76
76
|
if (!auditConfig?.fields?.length) return;
|
|
@@ -87,7 +87,7 @@ function applyAuditMiddleware(schema, collectionName) {
|
|
|
87
87
|
|
|
88
88
|
if (hasChanged) {
|
|
89
89
|
const newValue = update?.$set?.[field] ?? update?.[field];
|
|
90
|
-
const oldValue = this._originalDoc[field];
|
|
90
|
+
const oldValue = this._originalDoc ? this._originalDoc[field] : '';
|
|
91
91
|
|
|
92
92
|
if (oldValue !== newValue) {
|
|
93
93
|
// Resolve human-readable values
|