UNPKG

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.

24 lines (23 loc) 957 B
// @ts-nocheck import mysqlConnector from './mysqlConnector/index.mjs'; /** * 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. */ export default 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); } }); }