require("dotenv").config({ path: "./.env" });
import grabDSQLConnection from "../utils/grab-dsql-connection";

/**
 * # Main DB Handler Function
 * @async
 *
 * @param {object} params
 * @param {string} params.query
 * @param {string[] | object} [params.values]
 * @param {string} [params.database]
 *
 * @returns {Promise<object|null>}
 */
(async () => {
    const CONNECTION = grabDSQLConnection({ noDb: true });

    /**
     * Switch Database
     *
     * @description If a database is provided, switch to it
     */
    try {
        const result = await CONNECTION.query("SHOW DATABASES");

        const parsedResults = JSON.parse(JSON.stringify(result));

        console.log("parsedResults =>", parsedResults);
    } catch (error: any) {
        console.log("Connection query ERROR =>", error.message);
    } finally {
        CONNECTION?.end();
        process.exit();
    }
})();
