From a34714e19891c4e7a7e57fec5b4a8cd21e0494cd Mon Sep 17 00:00:00 2001 From: Semjon Geist Date: Wed, 22 Feb 2023 11:51:32 +0100 Subject: [PATCH] specify bulkOperation types --- .../lib/meta/api/dataApis/bulkDataAliasApis.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/dataApis/bulkDataAliasApis.ts b/packages/nocodb/src/lib/meta/api/dataApis/bulkDataAliasApis.ts index 217edcb231..b63a4edc69 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/bulkDataAliasApis.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/bulkDataAliasApis.ts @@ -1,4 +1,5 @@ import { Request, Response, Router } from 'express'; +import { BaseModelSqlv2 } from '../../../db/sql-data-mapper/lib/sql/BaseModelSqlv2'; import Model from '../../../models/Model'; import Base from '../../../models/Base'; import NcConnectionMgrv2 from '../../../utils/common/NcConnectionMgrv2'; @@ -16,8 +17,18 @@ async function getModelAndBase(req: Request) { async function executeBulkOperation( req: Request, res: Response, - operation: string, - options: any = {} + operation: + | 'bulkInsert' + | 'bulkUpdate' + | 'bulkUpdateAll' + | 'bulkDelete' + | 'bulkDeleteAll', + options: + | Parameters + | Parameters + | Parameters + | Parameters + | Parameters ) { const { model, view, base } = await getModelAndBase(req); const baseModel = await Model.getBaseModelSQL({ @@ -25,7 +36,7 @@ async function executeBulkOperation( viewId: view?.id, dbDriver: NcConnectionMgrv2.get(base), }); - res.json(await baseModel[operation](...options)); + res.json(await baseModel[operation].apply(null, options)); } async function bulkDataInsert(req: Request, res: Response) {