mirror of
https://github.com/hexastack/hexabot
synced 2024-11-25 21:37:59 +00:00
fix: preUpdate
This commit is contained in:
parent
8f815d468c
commit
b4bf2d4ff7
@ -265,7 +265,7 @@ export class BlockController extends BaseController<
|
||||
@Patch('bulk')
|
||||
async updateMany(@Body() body: { ids: string[]; payload: BlockUpdateDto }) {
|
||||
if (!body.ids || body.ids.length === 0) {
|
||||
throw new BadRequestException('No IDs provided for ...');
|
||||
throw new BadRequestException('No IDs provided to perform the update');
|
||||
}
|
||||
const updates = await this.blockService.updateMany(
|
||||
{
|
||||
|
@ -99,9 +99,14 @@ export class BlockRepository extends BaseRepository<
|
||||
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 }, $pull: { nextBlocks: movedBlockId } },
|
||||
{ $set: { attachedBlock: null } },
|
||||
);
|
||||
} else if (update?.category && !criteria._id) {
|
||||
throw new Error('Criteria must include a valid id to update category.');
|
||||
@ -154,7 +159,7 @@ export class BlockRepository extends BaseRepository<
|
||||
}
|
||||
}
|
||||
|
||||
private mapIdsAndCategory(
|
||||
mapIdsAndCategory(
|
||||
ids: string[],
|
||||
category: string,
|
||||
): {
|
||||
@ -166,7 +171,7 @@ export class BlockRepository extends BaseRepository<
|
||||
return { objIds, objCategory };
|
||||
}
|
||||
|
||||
private async updateBlocksInScope(
|
||||
async updateBlocksInScope(
|
||||
objCategory: mongoose.Types.ObjectId,
|
||||
ids: string[],
|
||||
): Promise<void> {
|
||||
@ -196,7 +201,7 @@ export class BlockRepository extends BaseRepository<
|
||||
}
|
||||
}
|
||||
|
||||
private async updateExternalBlocks(
|
||||
async updateExternalBlocks(
|
||||
otherBlocks,
|
||||
objIds: Types.ObjectId[],
|
||||
): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user