1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

refactor: improved structure of connection core

This commit is contained in:
2020-09-17 17:58:12 +02:00
parent 4991291c2c
commit 5334a44271
8 changed files with 309 additions and 349 deletions

View File

@@ -0,0 +1,27 @@
'use strict';
import { MySQLClient } from './clients/MySQLClient';
export class ClientsFactory {
/**
* Returns a database connection based on received args.
*
* @param {Object} args
* @param {String} args.client
* @param {Object} args.params
* @param {String} args.params.host
* @param {Number} args.params.port
* @param {String} args.params.password
* @param {Number=} args.poolSize
* @returns Database Connection
* @memberof ClientsFactory
*/
static getConnection (args) {
switch (args.client) {
case 'mysql':
case 'maria':
return new MySQLClient(args);
default:
return new Error(`Unknown database client: ${args.client}`);
}
}
}