tiny-essentials
Version:
Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.
31 lines (25 loc) • 942 B
JavaScript
;
require('clone');
require('../../v1/basics/objFilter.cjs');
// @ts-nocheck
/**
* Connects to a MySQL database using the provided configuration and credentials.
* The function utilizes `mySqlConnector.create` to establish the connection.
*
* @param {Record<string, any>} mysql - The MySQL module instance.
* @param {Array|string} databases - The list of databases to connect to, or a single database name.
* @param {Record<string, any>} cfg - The configuration object containing connection details (e.g., host, user, password).
* @returns {Promise} Resolves with the connection object or rejects with an error.
*/
function mySQL(mysql, databases, cfg) {
return new Promise(function (resolve, reject) {
// Get Module
try {
mySqlConnector.create(mysql, databases, cfg, 'firebase').then(resolve).catch(reject);
} catch (err) {
// Error
reject(err);
}
});
}
module.exports = mySQL;