From 2d2d50f3c98b9f3f8ace2b70a30a580d8e418cba Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 25 Mar 2023 17:52:24 +0800 Subject: [PATCH] refactor(nocodb): lower case on hook events --- .../sql-data-mapper/lib/sql/BaseModelSqlv2.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts index 9234f2866e..23fa267665 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts @@ -2107,11 +2107,11 @@ class BaseModelSqlv2 { * */ public async beforeInsert(data: any, _trx: any, req): Promise { - await this.handleHooks('Before.insert', null, data, req); + await this.handleHooks('before.insert', null, data, req); } public async afterInsert(data: any, _trx: any, req): Promise { - await this.handleHooks('After.insert', null, data, req); + await this.handleHooks('after.insert', null, data, req); const id = this._extractPksValues(data); await Audit.insert({ fk_model_id: this.model.id, @@ -2136,7 +2136,7 @@ class BaseModelSqlv2 { let noOfUpdatedRecords = data; if (!isBulkAllOperation) { noOfUpdatedRecords = data.length; - await this.handleHooks('After.update', null, data, req); + await this.handleHooks('after.update', null, data, req); } await Audit.insert({ @@ -2161,7 +2161,7 @@ class BaseModelSqlv2 { let noOfDeletedRecords = data; if (!isBulkAllOperation) { noOfDeletedRecords = data.length; - await this.handleHooks('After.delete', data, null, req); + await this.handleHooks('after.delete', data, null, req); } await Audit.insert({ @@ -2183,7 +2183,7 @@ class BaseModelSqlv2 { _trx: any, req ): Promise { - await this.handleHooks('After.insert', null, response, req); + await this.handleHooks('after.insert', null, response, req); await Audit.insert({ fk_model_id: this.model.id, @@ -2206,7 +2206,7 @@ class BaseModelSqlv2 { } } if (ignoreWebhook === undefined || ignoreWebhook === 'false') { - await this.handleHooks('Before.update', null, data, req); + await this.handleHooks('before.update', null, data, req); } } @@ -2236,12 +2236,12 @@ class BaseModelSqlv2 { } } if (ignoreWebhook === undefined || ignoreWebhook === 'false') { - await this.handleHooks('After.update', prevData, newData, req); + await this.handleHooks('after.update', prevData, newData, req); } } public async beforeDelete(data: any, _trx: any, req): Promise { - await this.handleHooks('Before.delete', null, data, req); + await this.handleHooks('before.delete', null, data, req); } public async afterDelete(data: any, _trx: any, req): Promise { @@ -2256,14 +2256,14 @@ class BaseModelSqlv2 { ip: req?.clientIp, user: req?.user?.email, }); - await this.handleHooks('After.delete', data, null, req); + await this.handleHooks('after.delete', data, null, req); } private async handleHooks(hookName, prevData, newData, req): Promise { const view = await View.get(this.viewId); // handle form view data submission - if (hookName === 'After.insert' && view.type === ViewTypes.FORM) { + if (hookName === 'after.insert' && view.type === ViewTypes.FORM) { try { const formView = await view.getView(); const { columns } = await FormView.getWithInfo(formView.fk_view_id);