Browse Source

chore: lint

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5379/head
Pranav C 2 years ago
parent
commit
12c5f6f0a7
  1. 11
      packages/nocodb/src/lib/controllers/dbData/oldData.ctl.ts
  2. 2
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts
  3. 2
      packages/nocodb/src/lib/services/dbData/helpers.ts
  4. 37
      packages/nocodb/src/lib/services/dbData/index.ts
  5. 20
      packages/nocodb/src/lib/services/public/publicData.svc.ts

11
packages/nocodb/src/lib/controllers/dbData/oldData.ctl.ts

@ -132,19 +132,14 @@ async function dataRead(req: Request, res: Response) {
dbDriver: await NcConnectionMgrv2.get(base), dbDriver: await NcConnectionMgrv2.get(base),
}); });
const {ast} = await getAst({ const { ast } = await getAst({
query: req.query, query: req.query,
model, model,
view, view,
}) });
res.json( res.json(
await nocoExecute( await nocoExecute(ast, await baseModel.readByPk(req.params.rowId), {}, {})
ast ,
await baseModel.readByPk(req.params.rowId),
{},
{}
)
); );
} }

2
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts

@ -836,7 +836,7 @@ export default async function formulaQueryBuilderv2(
tableAlias tableAlias
); );
if(!validateFormula) return qb; if (!validateFormula) return qb;
try { try {
// dry run qb.builder to see if it will break the grid view or not // dry run qb.builder to see if it will break the grid view or not

2
packages/nocodb/src/lib/services/dbData/helpers.ts

@ -242,7 +242,7 @@ export async function getDbRows(param: {
temp = process.hrtime(startTime), temp = process.hrtime(startTime),
elapsed = temp[0] * 1000 + temp[1] / 1000000 elapsed = temp[0] * 1000 + temp[1] / 1000000
) { ) {
const {ast, dependencyFields} = await getAst({ const { ast, dependencyFields } = await getAst({
query: query, query: query,
includePkByDefault: false, includePkByDefault: false,
model: view.model, model: view.model,

37
packages/nocodb/src/lib/services/dbData/index.ts

@ -116,7 +116,6 @@ export async function getDataList(param: {
const { ast, dependencyFields } = await getAst({ model, query, view }); const { ast, dependencyFields } = await getAst({ model, query, view });
const listArgs: any = dependencyFields; const listArgs: any = dependencyFields;
try { try {
listArgs.filterArr = JSON.parse(listArgs.filterArrJson); listArgs.filterArr = JSON.parse(listArgs.filterArrJson);
@ -128,12 +127,7 @@ export async function getDataList(param: {
let data = []; let data = [];
let count = 0; let count = 0;
try { try {
data = await nocoExecute( data = await nocoExecute(ast, await baseModel.list(listArgs), {}, listArgs);
ast,
await baseModel.list(listArgs),
{},
listArgs
);
count = await baseModel.count(listArgs); count = await baseModel.count(listArgs);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
@ -171,17 +165,10 @@ export async function getFindOne(param: {
args.sortArr = JSON.parse(args.sortArrJson); args.sortArr = JSON.parse(args.sortArrJson);
} catch (e) {} } catch (e) {}
const {ast, dependencyFields} = await getAst({ model, query: args, view }) const { ast, dependencyFields } = await getAst({ model, query: args, view });
const data = await baseModel.findOne({ ...args, dependencyFields }); const data = await baseModel.findOne({ ...args, dependencyFields });
return data return data ? await nocoExecute(ast, data, {}, {}) : {};
? await nocoExecute(
ast,
data,
{},
{}
)
: {};
} }
export async function getDataGroupBy(param: { export async function getDataGroupBy(param: {
@ -228,14 +215,9 @@ export async function dataRead(
NcError.notFound('Row not found'); NcError.notFound('Row not found');
} }
const { ast, dependencyFields } = await getAst({ model, query: param.query, view }) const { ast } = await getAst({ model, query: param.query, view });
return await nocoExecute( return await nocoExecute(ast, row, {}, param.query);
ast,
row,
{},
param.query
);
} }
export async function dataExist( export async function dataExist(
@ -303,12 +285,7 @@ export async function getGroupedDataList(param: {
...listArgs, ...listArgs,
groupColumnId: param.columnId, groupColumnId: param.columnId,
}); });
data = await nocoExecute( data = await nocoExecute({ key: 1, value: ast }, groupedData, {}, listArgs);
{ key: 1, value: ast },
groupedData,
{},
listArgs
);
const countArr = await baseModel.groupedListCount({ const countArr = await baseModel.groupedListCount({
...listArgs, ...listArgs,
groupColumnId: param.columnId, groupColumnId: param.columnId,
@ -655,7 +632,7 @@ export async function dataReadByViewId(param: {
dbDriver: await NcConnectionMgrv2.get(base), dbDriver: await NcConnectionMgrv2.get(base),
}); });
const { ast } = await getAst({ model, query: param.query }) const { ast } = await getAst({ model, query: param.query });
return await nocoExecute( return await nocoExecute(
ast, ast,

20
packages/nocodb/src/lib/services/public/publicData.svc.ts

@ -63,21 +63,16 @@ export async function dataList(param: {
query: param.query, query: param.query,
model, model,
view, view,
}) });
data = await nocoExecute( data = await nocoExecute(ast, await baseModel.list(listArgs), {}, listArgs);
ast,
await baseModel.list(listArgs),
{},
listArgs
);
count = await baseModel.count(listArgs); count = await baseModel.count(listArgs);
} catch (e) { } catch (e) {
console.log(e) console.log(e);
// show empty result instead of throwing error here // show empty result instead of throwing error here
// e.g. search some text in a numeric field // e.g. search some text in a numeric field
NcError.internalServerError('Please try after some time') NcError.internalServerError('Please try after some time');
} }
return new PagedResponseImpl(data, { ...param.query, count }); return new PagedResponseImpl(data, { ...param.query, count });
@ -153,12 +148,7 @@ async function getGroupedDataList(param: {
...listArgs, ...listArgs,
groupColumnId, groupColumnId,
}); });
data = await nocoExecute( data = await nocoExecute({ key: 1, value: ast }, groupedData, {}, listArgs);
{ key: 1, value: ast },
groupedData,
{},
listArgs
);
const countArr = await baseModel.groupedListCount({ const countArr = await baseModel.groupedListCount({
...listArgs, ...listArgs,
groupColumnId, groupColumnId,

Loading…
Cancel
Save