mirror of
https://github.com/strapi/strapi.git
synced 2025-07-22 16:37:13 +00:00
29 lines
549 B
JavaScript
29 lines
549 B
JavaScript
'use strict';
|
|
|
|
const getDialectClass = client => {
|
|
switch (client) {
|
|
case 'postgres':
|
|
return require('./postgresql');
|
|
case 'mysql':
|
|
return require('./mysql');
|
|
case 'sqlite':
|
|
return require('./sqlite');
|
|
default:
|
|
throw new Error(`Unknow dialect ${client}`);
|
|
}
|
|
};
|
|
|
|
const getDialect = db => {
|
|
const { client } = db.config.connection;
|
|
|
|
const constructor = getDialectClass(client);
|
|
const dialect = new constructor(db);
|
|
dialect.client = client;
|
|
|
|
return dialect;
|
|
};
|
|
|
|
module.exports = {
|
|
getDialect,
|
|
};
|