스크롤 기능 포함

This commit is contained in:
leeheejin
2025-09-23 10:45:53 +09:00
parent 37ded5a543
commit f160a33b94
9 changed files with 703 additions and 256 deletions

View File

@@ -0,0 +1,52 @@
import { DatabaseConnector, ConnectionConfig } from '../interfaces/DatabaseConnector';
import { PostgreSQLConnector } from './PostgreSQLConnector';
export class DatabaseConnectorFactory {
private static connectors = new Map<string, DatabaseConnector>();
static async createConnector(
type: string,
config: ConnectionConfig,
connectionId: number // Added connectionId for unique key
): Promise<DatabaseConnector> {
const key = `${type}-${connectionId}`; // Use connectionId for unique key
if (this.connectors.has(key)) {
return this.connectors.get(key)!;
}
let connector: DatabaseConnector;
switch (type.toLowerCase()) {
case 'postgresql':
connector = new PostgreSQLConnector(config);
break;
// Add other database types here
default:
throw new Error(`지원하지 않는 데이터베이스 타입: ${type}`);
}
this.connectors.set(key, connector);
return connector;
}
static async getConnector(connectionId: number, type: string): Promise<DatabaseConnector | undefined> {
const key = `${type}-${connectionId}`;
return this.connectors.get(key);
}
static async closeConnector(connectionId: number, type: string): Promise<void> {
const key = `${type}-${connectionId}`;
const connector = this.connectors.get(key);
if (connector) {
await connector.disconnect();
this.connectors.delete(key);
}
}
static async closeAll(): Promise<void> {
for (const connector of this.connectors.values()) {
await connector.disconnect();
}
this.connectors.clear();
}
}