fix: resolve conflicts

This commit is contained in:
hexastack
2024-10-31 17:06:28 +01:00
parent ce20bb725a
commit 310d9e47aa
2 changed files with 28 additions and 2 deletions

View File

@@ -89,12 +89,26 @@ export class BlockRepository extends BaseRepository<
Block,
'findOneAndUpdate'
>,
_criteria: TFilterQuery<Block>,
criteria: TFilterQuery<Block>,
_updates:
| UpdateWithAggregationPipeline
| UpdateQuery<Document<Block, any, any>>,
): Promise<void> {
const updates: BlockUpdateDto = _updates?.['$set'];
if (updates?.category) {
const movedBlockId = criteria._id;
// Find and update blocks that reference the moved block
await this.model.updateMany(
{ nextBlocks: movedBlockId },
{ $pull: { nextBlocks: movedBlockId } },
);
await this.model.updateMany(
{ attachedBlock: movedBlockId },
{ $set: { attachedBlock: null } },
);
}
this.checkDeprecatedAttachmentUrl(updates);
}