Browse Source

fix: exist api response correction

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 2 years ago
parent
commit
7eb10e32d0
  1. 3
      packages/nocodb-nest/src/db/BaseModelSqlv2.ts
  2. 9
      packages/nocodb-nest/src/modules/datas/bulk-data-alias/bulk-data-alias.controller.ts
  3. 10
      packages/nocodb-nest/src/modules/datas/data-alias.controller.ts
  4. 4
      packages/nocodb-nest/src/modules/datas/datas.module.ts

3
packages/nocodb-nest/src/db/BaseModelSqlv2.ts

@ -181,9 +181,8 @@ class BaseModelSqlv2 {
public async exist(id?: any): Promise<any> {
const qb = this.dbDriver(this.tnPath);
await this.selectObject({ qb });
const pks = this.model.primaryKeys;
if ((id + '').split('___').length != pks.length) {
if ((id + '').split('___').length != pks?.length) {
return false;
}
return !!(await qb.where(_wherePk(pks, id)).first());

9
packages/nocodb-nest/src/modules/datas/bulk-data-alias/bulk-data-alias.controller.ts

@ -1,11 +1,13 @@
import {
Body,
Controller,
Delete, HttpCode,
Delete,
HttpCode,
Param,
Patch,
Post,
Request,
Response,
UseGuards,
} from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport';
@ -25,16 +27,19 @@ export class BulkDataAliasController {
@Acl('bulkDataInsert')
async bulkDataInsert(
@Request() req,
@Response() res,
@Param('projectName') projectName: string,
@Param('tableName') tableName: string,
@Body() body: any,
) {
return await this.bulkDataAliasService.bulkDataInsert({
const exists = await this.bulkDataAliasService.bulkDataInsert({
body: body,
cookie: req,
projectName: projectName,
tableName: tableName,
});
res.json(exists);
}
@Patch('/api/v1/db/data/bulk/:orgs/:projectName/:tableName')

10
packages/nocodb-nest/src/modules/datas/data-alias.controller.ts

@ -2,14 +2,15 @@ import {
Body,
Controller,
Delete,
Get, HttpCode,
Get,
HttpCode,
Param,
Patch,
Post,
Request,
Response,
UseGuards,
} from '@nestjs/common'
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { parseHrtimeToSeconds } from '../../helpers';
import {
@ -201,18 +202,21 @@ export class DataAliasController {
@Acl('dataExist')
async dataExist(
@Request() req,
@Response() res,
@Param('projectName') projectName: string,
@Param('tableName') tableName: string,
@Param('viewName') viewName: string,
@Param('rowId') rowId: string,
) {
return await this.datasService.dataExist({
const exists = await this.datasService.dataExist({
projectName: projectName,
tableName: tableName,
viewName: viewName,
rowId: rowId,
query: req.query,
});
res.json(exists);
}
// todo: Handle the error case where view doesnt belong to model

4
packages/nocodb-nest/src/modules/datas/datas.module.ts

@ -12,12 +12,12 @@ import { OldDatasService } from './old-datas/old-datas.service';
@Module({
controllers: [
DataAliasController,
DatasController,
BulkDataAliasController,
DataAliasController,
DataAliasNestedController,
DataAliasExportController,
OldDatasController,
DataAliasNestedController,
],
providers: [
DatasService,

Loading…
Cancel
Save