mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 22:26:01 +00:00
create script callable from react
This commit is contained in:
@@ -1,7 +1,25 @@
|
||||
const _ = require("lodash");
|
||||
const mssql = require('./mssql');
|
||||
const mysql = require('./mysql');
|
||||
const postgres = require('./postgres');
|
||||
|
||||
const drivers = {
|
||||
mssql,
|
||||
mysql,
|
||||
postgres,
|
||||
}
|
||||
|
||||
/** @return {import('@dbgate/types').EngineDriver} */
|
||||
function getDriver(connection) {
|
||||
const { engine } = connection;
|
||||
return require(`./${engine}`);
|
||||
if (_.isString(connection)) {
|
||||
return drivers[connection];
|
||||
}
|
||||
if (_.isPlainObject(connection)) {
|
||||
const { engine } = connection;
|
||||
if (engine) {
|
||||
return drivers[engine];
|
||||
}
|
||||
}
|
||||
throw new Error(`Cannot extract engine from ${connection}`)
|
||||
}
|
||||
module.exports = getDriver;
|
||||
|
||||
Reference in New Issue
Block a user