@dynamatix/cat-shared 0.0.141 → 0.0.149
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.
|
@@ -426,12 +426,21 @@ function applyAuditMiddleware(schema, collectionName) {
|
|
|
426
426
|
async function updateContextAuditCount(contextId, count) {
|
|
427
427
|
count = Number(count);
|
|
428
428
|
if (!contextId || isNaN(count)) return;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
429
|
+
|
|
430
|
+
try {
|
|
431
|
+
const model = mongoose.models['Application'];
|
|
432
|
+
|
|
433
|
+
// Use direct collection access to bypass all Mongoose middleware
|
|
434
|
+
// This prevents workflow triggers from firing for audit count updates
|
|
435
|
+
await model.collection.updateOne(
|
|
436
|
+
{ _id: new mongoose.Types.ObjectId(contextId) },
|
|
437
|
+
{ $inc: { newAuditRecordsCount: count } },
|
|
438
|
+
{ upsert: false }
|
|
439
|
+
);
|
|
440
|
+
} catch (error) {
|
|
441
|
+
console.error('Error updating audit count:', error);
|
|
442
|
+
// Don't throw - audit count update failure shouldn't break the main operation
|
|
443
|
+
}
|
|
435
444
|
}
|
|
436
445
|
|
|
437
446
|
export function registerAuditHook(callback) {
|