Skip to content

Commit

Permalink
fix(core): cascadingRemove() behavior when the same ObjectId is sent
Browse files Browse the repository at this point in the history
  • Loading branch information
minenwerfer committed Oct 16, 2024
1 parent 2e710a8 commit 267667c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-foxes-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aeriajs/core": patch
---

Fix `cascadingRemove()` behavior when the same ObjectId is sent
4 changes: 4 additions & 0 deletions packages/core/src/collection/traverseDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ const cleanupReferences = async (value: unknown, ctx: PhaseContext) => {
}

referenceIds = referenceIds.filter((oldId) => !(value as ObjectId[]).some((valueId) => valueId.equals(oldId)))
} else {
if( referenceIds.equals(value as ObjectId) ) {
return value
}
}

const refMap = await getReferences(ctx.options.description.properties)
Expand Down

0 comments on commit 267667c

Please sign in to comment.