mirror of
https://github.com/hexastack/hexabot
synced 2025-02-24 21:34:31 +00:00
fix: throw if no updates has been provided to updateOne
This commit is contained in:
parent
4972011dfd
commit
aaa24656d3
@ -488,22 +488,24 @@ export abstract class BaseRepository<
|
|||||||
);
|
);
|
||||||
const filterCriteria = query.getFilter();
|
const filterCriteria = query.getFilter();
|
||||||
const queryUpdates = query.getUpdate();
|
const queryUpdates = query.getUpdate();
|
||||||
if (queryUpdates) {
|
|
||||||
await this.preUpdateValidate(filterCriteria, queryUpdates);
|
|
||||||
this.emitter.emit(
|
|
||||||
this.getEventName(EHook.preUpdateValidate),
|
|
||||||
filterCriteria,
|
|
||||||
queryUpdates,
|
|
||||||
);
|
|
||||||
|
|
||||||
await this.postUpdateValidate(filterCriteria, queryUpdates);
|
if (!queryUpdates) {
|
||||||
this.emitter.emit(
|
throw new Error('updateOne() query updates are not undefined');
|
||||||
this.getEventName(EHook.postUpdateValidate),
|
|
||||||
filterCriteria,
|
|
||||||
queryUpdates,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.preUpdateValidate(filterCriteria, queryUpdates);
|
||||||
|
this.emitter.emit(
|
||||||
|
this.getEventName(EHook.preUpdateValidate),
|
||||||
|
filterCriteria,
|
||||||
|
queryUpdates,
|
||||||
|
);
|
||||||
|
|
||||||
|
await this.postUpdateValidate(filterCriteria, queryUpdates);
|
||||||
|
this.emitter.emit(
|
||||||
|
this.getEventName(EHook.postUpdateValidate),
|
||||||
|
filterCriteria,
|
||||||
|
queryUpdates,
|
||||||
|
);
|
||||||
return await this.executeOne(query, this.cls);
|
return await this.executeOne(query, this.cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user