From 77347a3d4a9d92d5992bb0711c13c5877f5500ea Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 11 Apr 2023 13:41:53 +0800 Subject: [PATCH] fix: OldData - dataInsert --- .../datas/old-datas/old-datas.controller.ts | 18 ++++++++++++++++-- .../datas/old-datas/old-datas.service.ts | 6 +++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/nocodb-nest/src/modules/datas/old-datas/old-datas.controller.ts b/packages/nocodb-nest/src/modules/datas/old-datas/old-datas.controller.ts index d69b245be7..b0df6b30d0 100644 --- a/packages/nocodb-nest/src/modules/datas/old-datas/old-datas.controller.ts +++ b/packages/nocodb-nest/src/modules/datas/old-datas/old-datas.controller.ts @@ -48,7 +48,13 @@ export class OldDatasController { @Param('projectId') projectId: string, @Param('tableName') tableName: string, ) { - res.json(await this.oldDatasService.getDataCount(req)); + res.json( + await this.oldDatasService.dataCount({ + query: req.query, + projectId: projectId, + tableName: tableName, + }), + ); } @Post('/nc/:projectId/api/v1/:tableName') @@ -58,8 +64,16 @@ export class OldDatasController { @Response() res, @Param('projectId') projectId: string, @Param('tableName') tableName: string, + @Body() body: any, ) { - res.json(await this.oldDatasService.dataInsert(req)); + res.json( + await this.oldDatasService.dataInsert({ + projectId: projectId, + tableName: tableName, + body: body, + cookie: req, + }), + ); } @Get('/nc/:projectId/api/v1/:tableName/:rowId') diff --git a/packages/nocodb-nest/src/modules/datas/old-datas/old-datas.service.ts b/packages/nocodb-nest/src/modules/datas/old-datas/old-datas.service.ts index f58d87d25b..026b48150b 100644 --- a/packages/nocodb-nest/src/modules/datas/old-datas/old-datas.service.ts +++ b/packages/nocodb-nest/src/modules/datas/old-datas/old-datas.service.ts @@ -43,7 +43,7 @@ export class OldDatasService { return await nocoExecute(ast, await baseModel.list(listArgs), {}, listArgs); } - async getDataCount(param: OldPathParams & { query: any }) { + async dataCount(param: OldPathParams & { query: any }) { const { model, view } = await this.getViewAndModelFromRequest(param); const base = await Base.get(model.base_id); @@ -61,7 +61,7 @@ export class OldDatasService { return await baseModel.count(listArgs); } - async dataInsert(param: OldPathParams & { body: unknown }) { + async dataInsert(param: OldPathParams & { body: unknown; cookie: any }) { const { model, view } = await this.getViewAndModelFromRequest(param); const base = await Base.get(model.base_id); @@ -72,7 +72,7 @@ export class OldDatasService { dbDriver: await NcConnectionMgrv2.get(base), }); - return await baseModel.insert(param.body, null, param); + return await baseModel.insert(param.body, null, param.cookie); } async dataRead(param: OldPathParams & { query: any; rowId: string }) {