forked from knex/knex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (34 loc) · 1.28 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.getDialectByNameOrAlias = void 0;
const { resolveClientNameWithAliases } = require('../util/helpers');
const dbNameToDialectLoader = Object.freeze({
'better-sqlite3': () => require('./better-sqlite3'),
cockroachdb: () => require('./cockroachdb'),
mssql: () => require('./mssql'),
mysql: () => require('./mysql'),
mysql2: () => require('./mysql2'),
oracle: () => require('./oracle'),
oracledb: () => require('./oracledb'),
pgnative: () => require('./pgnative'),
postgres: () => require('./postgres'),
redshift: () => require('./redshift'),
sqlite3: () => require('./sqlite3'),
});
/**
* Gets the Dialect object with the given client name or throw an
* error if not found.
*
* NOTE: This is a replacement for prior practice of doing dynamic
* string construction for imports of Dialect objects.
*/
function getDialectByNameOrAlias(clientName) {
const resolvedClientName = resolveClientNameWithAliases(clientName);
const dialectLoader = dbNameToDialectLoader[resolvedClientName];
if (!dialectLoader) {
throw new Error(`Invalid clientName given: ${clientName}`);
}
return dialectLoader();
}
exports.getDialectByNameOrAlias = getDialectByNameOrAlias;
//# sourceMappingURL=index.js.map