dbgate/packages/engines/index.js
Jan Prochazka e903122c52 tsfix
2020-02-03 20:44:06 +01:00

26 lines
565 B
JavaScript

const _ = require("lodash");
const mssql = require("./mssql");
const mysql = require("./mysql");
const postgres = require("./postgres");
const drivers = {
mssql,
mysql,
postgres
};
/** @type {import('@dbgate/types').EngineDriver} */
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;