From 518c21ceffef8e5e8c5f808091650fa8f6664a75 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 11 Apr 2023 13:06:58 +0800 Subject: [PATCH] feat: OldDatasController - dataCount --- .../datas/old-datas/old-datas.controller.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 2e24579121..70c1352379 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 @@ -8,12 +8,14 @@ import { Patch, Post, Request, + Response, } from '@nestjs/common'; import { Acl, ExtractProjectIdMiddleware, } from '../../../middlewares/extract-project-id/extract-project-id.middleware'; import { AuthGuard } from '@nestjs/passport'; +import { Project } from 'src/models'; import { DatasService } from '../datas.service'; @Controller() @@ -32,4 +34,23 @@ export class OldDatasController { query: req.query, }); } + + @Get('/nc/:projectId/api/v1/:tableName/count') + @Acl('dataCount') + async dataCount( + @Request() req, + @Response() res, + @Param('tableName') tableName: string, + ) { + const { model, view } = + await this.datasService.getViewAndModelFromRequestByAliasOrId(req); + const project = await Project.get(model.project_id); + const countResult = await this.datasService.dataCount({ + query: req.query, + projectName: project.title, + tableName: tableName, + viewName: view.title, + }); + res.json(countResult); + } }