From f6fdec1226c60754251179cf0393401db6964b62 Mon Sep 17 00:00:00 2001 From: Chareice Date: Thu, 14 Dec 2023 21:16:10 +0800 Subject: [PATCH] chore(database): update event listener scope in collection --- packages/core/database/src/collection.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/core/database/src/collection.ts b/packages/core/database/src/collection.ts index ceecfc848..eb9ed4b42 100644 --- a/packages/core/database/src/collection.ts +++ b/packages/core/database/src/collection.ts @@ -699,6 +699,17 @@ export class Collection< }; } + protected bindFieldEventListener() { + this.on('field.afterAdd', (field: Field) => { + field.bind(); + }); + + this.on('field.afterRemove', (field: Field) => { + field.unbind(); + this.db.emit('field.afterRemove', field); + }); + } + private checkOptions(options: CollectionOptions) { checkIdentifier(options.name); this.checkTableName(); @@ -716,15 +727,4 @@ export class Collection< } } } - - private bindFieldEventListener() { - this.on('field.afterAdd', (field: Field) => { - field.bind(); - }); - - this.on('field.afterRemove', (field: Field) => { - field.unbind(); - this.db.emit('field.afterRemove', field); - }); - } }