mirror of
https://github.com/knex/knex.git
synced 2025-07-14 04:20:43 +00:00
39 lines
730 B
JavaScript
39 lines
730 B
JavaScript
![]() |
function isPostgreSQL(knex) {
|
||
|
return knex.client.driverName === 'pg';
|
||
|
}
|
||
|
|
||
|
function isOracle(knex) {
|
||
|
return /oracle/i.test(knex.client.driverName);
|
||
|
}
|
||
|
|
||
|
function isMysql(knex) {
|
||
|
return /mysql/i.test(knex.client.driverName);
|
||
|
}
|
||
|
|
||
|
function isRedshift(knex) {
|
||
|
return knex.client.driverName === 'redshift';
|
||
|
}
|
||
|
|
||
|
function isSQLite(knex) {
|
||
|
return knex.client.driverName === 'sqlite3';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @param knex
|
||
|
* @param {('pg'|'oracledb'|'mysql'|'mysql2'|'mssql'|'sqlite3')[]} supportedDbs - supported DB values
|
||
|
* @returns {*}
|
||
|
*/
|
||
|
function isOneOfDbs(knex, supportedDbs) {
|
||
|
return supportedDbs.includes(knex.client.driverName);
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
isOneOfDbs,
|
||
|
isMysql,
|
||
|
isOracle,
|
||
|
isPostgreSQL,
|
||
|
isRedshift,
|
||
|
isSQLite,
|
||
|
};
|