Browse Source

refactor(nocodb): add async / await

pull/5262/head
Wing-Kam Wong 2 years ago
parent
commit
f7f9039ea9
  1. 2
      packages/nocodb/src/lib/db/sql-migrator/lib/KnexMigratorv2.ts
  2. 2
      packages/nocodb/src/lib/meta/api/helpers/populateMeta.ts
  3. 4
      packages/nocodb/src/lib/meta/helpers/getColumnPropsFromUIDT.ts
  4. 2
      packages/nocodb/src/lib/services/base.svc.ts
  5. 6
      packages/nocodb/src/lib/services/column.svc.ts
  6. 2
      packages/nocodb/src/lib/services/table.svc.ts

2
packages/nocodb/src/lib/db/sql-migrator/lib/KnexMigratorv2.ts

@ -384,7 +384,7 @@ export default class KnexMigratorv2 {
async _initDbWithSql(base: Base) {
const sqlClient = await this.getSqlClient(base);
const connectionConfig = base.getConnectionConfig();
const connectionConfig = await base.getConnectionConfig();
if (connectionConfig.client === 'oracledb') {
this.emit(
`${connectionConfig.client}: Creating DB if not exists ${connectionConfig.connection.user}`

2
packages/nocodb/src/lib/meta/api/helpers/populateMeta.ts

@ -22,7 +22,7 @@ export async function populateMeta(base: Base, project: Project): Promise<any> {
tablesCount: 0,
relationsCount: 0,
viewsCount: 0,
client: base?.getConnectionConfig()?.client,
client: (await base?.getConnectionConfig())?.client,
timeTaken: 0,
};

4
packages/nocodb/src/lib/meta/helpers/getColumnPropsFromUIDT.ts

@ -7,11 +7,11 @@ import {
import Base from '../../models/Base';
import Column from '../../models/Column';
export default function getColumnPropsFromUIDT(
export default async function getColumnPropsFromUIDT(
column: ColumnReqType & { altered?: number },
base: Base
) {
const sqlUi = SqlUiFactory.create(base.getConnectionConfig());
const sqlUi = SqlUiFactory.create(await base.getConnectionConfig());
const colProp = sqlUi.getDataTypeForUiType(
column as Column,

2
packages/nocodb/src/lib/services/base.svc.ts

@ -8,7 +8,7 @@ import { populateMeta, validatePayload } from '../meta/api/helpers';
export async function baseGetWithConfig(param: { baseId: any }) {
const base = await Base.get(param.baseId);
base.config = base.getConnectionConfig();
base.config = await base.getConnectionConfig();
return base;
}

6
packages/nocodb/src/lib/services/column.svc.ts

@ -167,7 +167,7 @@ export async function columnUpdate(param: {
} else if (
[UITypes.SingleSelect, UITypes.MultiSelect].includes(colBody.uidt)
) {
colBody = getColumnPropsFromUIDT(colBody, base);
colBody = await getColumnPropsFromUIDT(colBody, base);
const baseModel = await Model.getBaseModelSQL({
id: table.id,
@ -750,7 +750,7 @@ export async function columnUpdate(param: {
...colBody,
});
} else {
colBody = getColumnPropsFromUIDT(colBody, base);
colBody = await getColumnPropsFromUIDT(colBody, base);
const tableUpdateBody = {
...table,
tn: table.table_name,
@ -947,7 +947,7 @@ export async function columnAdd(param: {
break;
default:
{
colBody = getColumnPropsFromUIDT(colBody, base);
colBody = await getColumnPropsFromUIDT(colBody, base);
if (colBody.uidt === UITypes.Duration) {
colBody.dtxp = '20';
// by default, colBody.dtxs is 2

2
packages/nocodb/src/lib/services/table.svc.ts

@ -410,7 +410,7 @@ export async function tableCreate(param: {
}
}
tableCreatePayLoad.columns = param.table.columns?.map((c) => ({
tableCreatePayLoad.columns = param.table.columns?.map(async (c) => ({
...getColumnPropsFromUIDT(c as any, base),
cn: c.column_name,
column_name: c.column_name,

Loading…
Cancel
Save