@js-ak/db-manager
Version:
58 lines (57 loc) • 2.26 kB
TypeScript
import mysql from "mysql2/promise";
import { MYSQL } from "../../index.js";
/**
* Creates a MySQL connection with the given configuration.
*
* @param config - The configuration options for the MySQL connection.
*
* @returns The MySQL connection.
*/
export declare const createConnection: (config: mysql.ConnectionOptions) => Promise<mysql.Connection>;
/**
* Retrieves or creates a standard connection pool.
*
* @param config - The database credentials configuration object.
* @param [poolName="shared"] - The name suffix for the pool, default is "shared".
*
* @returns The retrieved or newly created standard connection pool.
*/
export declare const getStandardPool: (config: MYSQL.ModelTypes.TDBCreds, poolName?: string) => mysql.Pool;
/**
* Retrieves or creates a transaction-specific connection pool.
*
* @param config - The database credentials configuration object.
* @param [poolName="shared"] - The name suffix for the pool, default is "shared".
*
* @returns The retrieved or newly created transaction connection pool.
*/
export declare const getTransactionPool: (config: MYSQL.ModelTypes.TDBCreds, poolName?: string) => mysql.Pool;
/**
* Removes and closes a standard connection pool.
*
* @param config - The database credentials configuration object.
* @param [poolName="shared"] - The name suffix for the pool, default is "shared".
*
* @returns A promise that resolves when the pool is closed.
*/
export declare const removeStandardPool: (config: MYSQL.ModelTypes.TDBCreds, poolName?: string) => Promise<void>;
/**
* Removes and closes a transaction-specific connection pool.
*
* @param config - The database credentials configuration object.
* @param [poolName="shared"] - The name suffix for the pool, default is "shared".
*
* @returns A promise that resolves when the pool is closed.
*/
export declare const removeTransactionPool: (config: MYSQL.ModelTypes.TDBCreds, poolName?: string) => Promise<void>;
/**
* Gracefully shuts down all active connection pools.
*
* @param options - The options object.
* @param options.poolName - The pool name to match.
*
* @returns A promise that resolves when all pools are closed.
*/
export declare const shutdown: (options?: {
poolName?: string;
}) => Promise<void>;