fix: throw if no updates has been provided to updateOne

This commit is contained in:
abdou6666 2024-12-20 08:57:21 +01:00
parent 4972011dfd
commit aaa24656d3

View File

@ -488,7 +488,11 @@ export abstract class BaseRepository<
);
const filterCriteria = query.getFilter();
const queryUpdates = query.getUpdate();
if (queryUpdates) {
if (!queryUpdates) {
throw new Error('updateOne() query updates are not undefined');
}
await this.preUpdateValidate(filterCriteria, queryUpdates);
this.emitter.emit(
this.getEventName(EHook.preUpdateValidate),
@ -502,8 +506,6 @@ export abstract class BaseRepository<
filterCriteria,
queryUpdates,
);
}
return await this.executeOne(query, this.cls);
}