mirror of
https://github.com/hexastack/hexabot
synced 2025-02-24 13:26:57 +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 queryUpdates = query.getUpdate();
|
||||
if (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,
|
||||
);
|
||||
if (!queryUpdates) {
|
||||
throw new Error('updateOne() query updates are not undefined');
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user