diff --git a/src/database/database.js b/src/database/database.js index 292bef6..04dfde9 100644 --- a/src/database/database.js +++ b/src/database/database.js @@ -833,7 +833,7 @@ export const editObject = async ({ model, id, updateData, user, populate, recalc // Audit log before update await editAuditLog( previousExpandedObject, - { ...previousExpandedObject, ...updateData }, + { ...previousExpandedObject, ...expandObjectIds(updateData) }, id, parentType, user @@ -846,7 +846,7 @@ export const editObject = async ({ model, id, updateData, user, populate, recalc ) { await editNotification( previousExpandedObject, - { ...previousExpandedObject, ...updateData }, + { ...previousExpandedObject, ...expandObjectIds(updateData) }, id, parentType, user @@ -857,11 +857,11 @@ export const editObject = async ({ model, id, updateData, user, populate, recalc // Call childUpdate event for any child objects await distributeChildUpdate( previousExpandedObject, - { ...previousExpandedObject, ...updateData }, + { ...previousExpandedObject, ...expandObjectIds(updateData) }, id, model ); - const updatedObject = { ...previousExpandedObject, ...updateData }; + const updatedObject = { ...previousExpandedObject, ...expandObjectIds(updateData) }; // Update cache with the new version await updateObjectCache({ diff --git a/src/utils.js b/src/utils.js index d537e3a..523600a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -667,7 +667,7 @@ async function newAuditLog(newValue, parentId, parentType, user) { await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); } async function editAuditLog(oldValue, newValue, parentId, parentType, user) { @@ -698,7 +698,7 @@ async function editAuditLog(oldValue, newValue, parentId, parentType, user) { await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); } async function editNotification(oldValue, newValue, parentId, parentType, user) { @@ -747,7 +747,7 @@ async function deleteAuditLog(deleteValue, parentId, parentType, user) { await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); } async function deleteNotification(object, parentId, parentType, user) { @@ -799,7 +799,7 @@ async function subscribeAuditLog(parentId, parentType, user) { operation: 'subscribe', }); await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); return auditLog; } @@ -812,7 +812,7 @@ async function unsubscribeAuditLog(parentId, parentType, user) { operation: 'unsubscribe', }); await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); return auditLog; }