From 97750ee3711ef77ab8142669b71930673e1fd69c Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 1 Mar 2023 19:14:56 +0800 Subject: [PATCH] feat(nocodb): expose DB_TYPES --- packages/nocodb/src/lib/models/Base.ts | 19 +++++++++++-------- packages/nocodb/src/lib/models/Project.ts | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/nocodb/src/lib/models/Base.ts b/packages/nocodb/src/lib/models/Base.ts index 0e3c4eca32..e8e2cf49c0 100644 --- a/packages/nocodb/src/lib/models/Base.ts +++ b/packages/nocodb/src/lib/models/Base.ts @@ -14,19 +14,22 @@ import { extractProps } from '../meta/helpers/extractProps'; import { NcError } from '../meta/helpers/catchError'; import SyncSource from './SyncSource'; +export const DB_TYPES = [ + 'mysql2', + 'sqlite', + 'mysql', + 'mssql', + 'snowflake', + 'oracledb', + 'pg', +]; + // todo: hide credentials export default class Base implements BaseType { id?: string; project_id?: string; alias?: string; - type?: - | 'mysql2' - | 'sqlite' - | 'mysql' - | 'mssql' - | 'snowflake' - | 'oracledb' - | 'pg'; + type?: typeof DB_TYPES[number]; is_meta?: BoolType; config?: string; created_at?: string; diff --git a/packages/nocodb/src/lib/models/Project.ts b/packages/nocodb/src/lib/models/Project.ts index 5ee799d1ab..7e0fb08217 100644 --- a/packages/nocodb/src/lib/models/Project.ts +++ b/packages/nocodb/src/lib/models/Project.ts @@ -1,4 +1,4 @@ -import Base from './/Base'; +import Base, { DB_TYPES } from './/Base'; import Noco from '../Noco'; import { BoolType, MetaType, ProjectType } from 'nocodb-sdk'; import { @@ -68,7 +68,7 @@ export default class Project implements ProjectType { for (const base of project.bases) { await Base.createBase( { - type: base.config?.client, + type: base.config?.client as typeof DB_TYPES[number], ...base, projectId, },