fix(repository): ensure category update check before processing blocks

This commit is contained in:
medchedli 2025-05-28 15:44:01 +01:00
parent 4692339bea
commit e671f0ab24

View File

@ -131,8 +131,9 @@ export class BlockRepository extends BaseRepository<
criteria: TFilterQuery<Block>, criteria: TFilterQuery<Block>,
updates: UpdateQuery<Document<Block, any, any>>, updates: UpdateQuery<Document<Block, any, any>>,
): Promise<void> { ): Promise<void> {
const categoryId: string = updates.$set.category; // Only proceed if category is being updated
if (categoryId) { if (updates.$set?.category) {
const categoryId: string = updates.$set.category;
const movedBlocks = await this.find(criteria); const movedBlocks = await this.find(criteria);
if (movedBlocks.length) { if (movedBlocks.length) {