nestjs-reverse-engineering
Version:
A powerful TypeScript/NestJS library for database reverse engineering, entity generation, and CRUD operations
49 lines • 2.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaIntrospectorFactory = void 0;
const database_types_1 = require("../types/database.types");
const postgres_introspector_1 = require("./postgres-introspector");
const mysql_introspector_1 = require("./mysql-introspector");
class SchemaIntrospectorFactory {
static create(dataSource) {
const driverType = dataSource.options.type;
switch (driverType) {
case 'postgres':
return new postgres_introspector_1.PostgresSchemaIntrospector(dataSource);
case 'mysql':
case 'mariadb':
return new mysql_introspector_1.MySQLSchemaIntrospector(dataSource);
case 'mssql':
// TODO: Implement MSSQL introspector
throw new Error('MSSQL introspector not implemented yet');
case 'sqlite':
// TODO: Implement SQLite introspector
throw new Error('SQLite introspector not implemented yet');
case 'oracle':
// TODO: Implement Oracle introspector
throw new Error('Oracle introspector not implemented yet');
default:
throw new Error(`Unsupported database type: ${driverType}`);
}
}
static getDialectFromDataSource(dataSource) {
const driverType = dataSource.options.type;
switch (driverType) {
case 'postgres':
return database_types_1.DatabaseDialect.POSTGRES;
case 'mysql':
case 'mariadb':
return database_types_1.DatabaseDialect.MYSQL;
case 'mssql':
return database_types_1.DatabaseDialect.MSSQL;
case 'sqlite':
return database_types_1.DatabaseDialect.SQLITE;
case 'oracle':
return database_types_1.DatabaseDialect.ORACLE;
default:
throw new Error(`Unsupported database type: ${driverType}`);
}
}
}
exports.SchemaIntrospectorFactory = SchemaIntrospectorFactory;
//# sourceMappingURL=introspector-factory.js.map