refactor: move codes into src folder

This commit is contained in:
steven
2023-03-31 16:12:09 +08:00
parent 483e750bc5
commit 861a22f13d
57 changed files with 44 additions and 8 deletions

View File

@ -0,0 +1,22 @@
import { Connection, Engine } from "@/types";
import mysql from "./mysql";
import postgres from "./postgres";
export interface Connector {
testConnection: () => Promise<boolean>;
execute: (databaseName: string, statement: string) => Promise<any>;
getDatabases: () => Promise<string[]>;
getTables: (databaseName: string) => Promise<string[]>;
getTableStructure: (databaseName: string, tableName: string) => Promise<string>;
}
export const newConnector = (connection: Connection): Connector => {
switch (connection.engineType) {
case Engine.MySQL:
return mysql(connection);
case Engine.PostgreSQL:
return postgres(connection);
default:
throw new Error("Unsupported engine type.");
}
};