mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: hooks names
This commit is contained in:
parent
b8d8bfeaa6
commit
d0ab39f6c3
@ -40,7 +40,7 @@ export class SettingRepository extends BaseRepository<Setting> {
|
|||||||
*
|
*
|
||||||
* @param setting The `Setting` document to be validated.
|
* @param setting The `Setting` document to be validated.
|
||||||
*/
|
*/
|
||||||
async postValidate(
|
async preCreateValidate(
|
||||||
setting: Document<unknown, unknown, Setting> &
|
setting: Document<unknown, unknown, Setting> &
|
||||||
Setting & { _id: Types.ObjectId },
|
Setting & { _id: Types.ObjectId },
|
||||||
) {
|
) {
|
||||||
|
|||||||
@ -86,12 +86,12 @@ export abstract class BaseRepository<
|
|||||||
|
|
||||||
hooks?.validate.pre.execute(async function () {
|
hooks?.validate.pre.execute(async function () {
|
||||||
const doc = this as HydratedDocument<T>;
|
const doc = this as HydratedDocument<T>;
|
||||||
await repository.preValidate(doc);
|
await repository.preCreateValidate(doc);
|
||||||
repository.emitter.emit(repository.getEventName(EHook.preValidate), doc);
|
repository.emitter.emit(repository.getEventName(EHook.preValidate), doc);
|
||||||
});
|
});
|
||||||
|
|
||||||
hooks?.validate.post.execute(async function (created: HydratedDocument<T>) {
|
hooks?.validate.post.execute(async function (created: HydratedDocument<T>) {
|
||||||
await repository.postValidate(created);
|
await repository.postCreateValidate(created);
|
||||||
repository.emitter.emit(
|
repository.emitter.emit(
|
||||||
repository.getEventName(EHook.postValidate),
|
repository.getEventName(EHook.postValidate),
|
||||||
created,
|
created,
|
||||||
@ -479,11 +479,11 @@ export abstract class BaseRepository<
|
|||||||
return await this.model.deleteMany(criteria);
|
return await this.model.deleteMany(criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
async preValidate(_doc: HydratedDocument<T>): Promise<void> {
|
async preCreateValidate(_doc: HydratedDocument<T>): Promise<void> {
|
||||||
// Nothing ...
|
// Nothing ...
|
||||||
}
|
}
|
||||||
|
|
||||||
async postValidate(_validated: HydratedDocument<T>): Promise<void> {
|
async postCreateValidate(_validated: HydratedDocument<T>): Promise<void> {
|
||||||
// Nothing ...
|
// Nothing ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user