mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
25 lines
513 B
JavaScript
25 lines
513 B
JavaScript
const _ = require("lodash");
|
|
const mssql = require("./mssql");
|
|
const mysql = require("./mysql");
|
|
const postgres = require("./postgres");
|
|
|
|
const drivers = {
|
|
mssql,
|
|
mysql,
|
|
postgres
|
|
};
|
|
|
|
function getDriver(connection) {
|
|
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;
|