Browse Source

fix: typo corrections

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5901/head
Pranav C 2 years ago
parent
commit
ae1a31b403
  1. 2
      packages/nocodb/src/controllers/data-table.controller.ts
  2. 4
      packages/nocodb/src/db/BaseModelSqlv2.ts
  3. 2
      packages/nocodb/src/modules/datas/datas.module.ts
  4. 77
      packages/nocodb/src/services/data-table.service.ts

2
packages/nocodb/src/controllers/data-table.controller.ts

@ -164,6 +164,7 @@ export class DataTableController {
viewId, viewId,
columnId, columnId,
refRowIds, refRowIds,
cookie: req,
}); });
} }
@ -185,6 +186,7 @@ export class DataTableController {
viewId, viewId,
columnId, columnId,
refRowIds, refRowIds,
cookie: req,
}); });
} }
} }

4
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -3613,7 +3613,9 @@ class BaseModelSqlv2 {
// .where(_wherePk(childTable.primaryKeys, rowId)) // .where(_wherePk(childTable.primaryKeys, rowId))
// .first(), // .first(),
// }); // });
await this.dbDriver(vTn).bulkInsert(insertData);
// todo: use bulk insert
await this.dbDriver(vTn).insert(insertData);
// } // }
} }
break; break;

2
packages/nocodb/src/modules/datas/datas.module.ts

@ -29,7 +29,7 @@ import { PublicDatasService } from '../../services/public-datas.service';
}), }),
], ],
controllers: [ controllers: [
process.env.NC_WORKER_CONTAINER !== 'true' ...(process.env.NC_WORKER_CONTAINER !== 'true'
? [ ? [
DataTableController, DataTableController,
DatasController, DatasController,

77
packages/nocodb/src/services/data-table.service.ts

@ -1,11 +1,16 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { RelationTypes, UITypes } from 'nocodb-sdk' import { RelationTypes, UITypes } from 'nocodb-sdk';
import { NcError } from '../helpers/catchError'; import { NcError } from '../helpers/catchError';
import { PagedResponseImpl } from '../helpers/PagedResponse' import { PagedResponseImpl } from '../helpers/PagedResponse';
import { Base, Column, LinkToAnotherRecordColumn, Model, View } from '../models' import { Base, Column, Model, View } from '../models';
import { getColumnByIdOrName, getViewAndModelByAliasOrId, PathParams } from '../modules/datas/helpers' import {
getColumnByIdOrName,
getViewAndModelByAliasOrId,
PathParams,
} from '../modules/datas/helpers';
import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2';
import { DatasService } from './datas.service'; import { DatasService } from './datas.service';
import type { LinkToAnotherRecordColumn } from '../models';
@Injectable() @Injectable()
export class DataTableService { export class DataTableService {
@ -250,14 +255,13 @@ export class DataTableService {
viewId: view?.id, viewId: view?.id,
dbDriver: await NcConnectionMgrv2.get(base), dbDriver: await NcConnectionMgrv2.get(base),
}); });
const column = await this.getColumn(param) const column = await this.getColumn(param);
const colOptions = await column.getColOptions<LinkToAnotherRecordColumn>( const colOptions = await column.getColOptions<LinkToAnotherRecordColumn>();
)
let data:any[] ; let data: any[];
let count:number; let count: number;
if(colOptions.type === RelationTypes.MANY_TO_MANY) { if (colOptions.type === RelationTypes.MANY_TO_MANY) {
data = await baseModel.mmList( data = await baseModel.mmList(
{ {
colId: column.id, colId: column.id,
@ -265,11 +269,11 @@ export class DataTableService {
}, },
param.query as any, param.query as any,
); );
count = await baseModel.mmListCount({ count = (await baseModel.mmListCount({
colId: column.id, colId: column.id,
parentId: param.rowId, parentId: param.rowId,
}); })) as number;
}else { } else {
data = await baseModel.hmList( data = await baseModel.hmList(
{ {
colId: column.id, colId: column.id,
@ -277,10 +281,10 @@ export class DataTableService {
}, },
param.query as any, param.query as any,
); );
count = await baseModel.hmListCount({ count = (await baseModel.hmListCount({
colId: column.id, colId: column.id,
id: param.rowId, id: param.rowId,
}); })) as number;
} }
return new PagedResponseImpl(data, { return new PagedResponseImpl(data, {
count, count,
@ -288,20 +292,28 @@ export class DataTableService {
}); });
} }
private async getColumn(param: {modelId: string; columnId: string }) { private async getColumn(param: { modelId: string; columnId: string }) {
const column = await Column.get({ colId: param.columnId }) const column = await Column.get({ colId: param.columnId });
if (!column) NcError.badRequest('Column not found' if (!column) NcError.badRequest('Column not found');
if (column.fk_model_id !== param.modelId) if (column.fk_model_id !== param.modelId)
NcError.badRequest('Column not belong to model') NcError.badRequest('Column not belong to model');
if (column.uidt !== UITypes.LinkToAnotherRecord) if (column.uidt !== UITypes.LinkToAnotherRecord)
NcError.badRequest('Column is not LTAR') NcError.badRequest('Column is not LTAR');
return column return column;
} }
async nestedLink(param: { cookie:any;viewId: string; modelId: string; columnId: string; query: any; refRowIds: string | string[] | number | number[]; rowId: string }) { async nestedLink(param: {
cookie: any;
viewId: string;
modelId: string;
columnId: string;
query: any;
refRowIds: string | string[] | number | number[];
rowId: string;
}) {
const { model, view } = await this.getModelAndView(param); const { model, view } = await this.getModelAndView(param);
if (!model) NcError.notFound('Table not found'); if (!model) NcError.notFound('Table not found');
@ -317,14 +329,25 @@ export class DataTableService {
await baseModel.addLinks({ await baseModel.addLinks({
colId: column.id, colId: column.id,
childIds: Array.isArray(param.refRowIds) ? param.refRowIds : [param.refRowIds], childIds: Array.isArray(param.refRowIds)
? param.refRowIds
: [param.refRowIds],
rowId: param.rowId, rowId: param.rowId,
cookie: param.cookie, cookie: param.cookie,
}); });
return true; } return true;
}
async nestedUnlink(param: { cookie:any;viewId: string; modelId: string; columnId: string; query: any; refRowIds: string | string[] | number | number[]; rowId: string }) { async nestedUnlink(param: {
cookie: any;
viewId: string;
modelId: string;
columnId: string;
query: any;
refRowIds: string | string[] | number | number[];
rowId: string;
}) {
const { model, view } = await this.getModelAndView(param); const { model, view } = await this.getModelAndView(param);
if (!model) NcError.notFound('Table not found'); if (!model) NcError.notFound('Table not found');
@ -340,7 +363,9 @@ export class DataTableService {
await baseModel.removeLinks({ await baseModel.removeLinks({
colId: column.id, colId: column.id,
childIds: Array.isArray(param.refRowIds) ? param.refRowIds : [param.refRowIds], childIds: Array.isArray(param.refRowIds)
? param.refRowIds
: [param.refRowIds],
rowId: param.rowId, rowId: param.rowId,
cookie: param.cookie, cookie: param.cookie,
}); });

Loading…
Cancel
Save