@athenna/database
Version:
The Athenna database handler for SQL/NoSQL.
73 lines (72 loc) • 2.42 kB
TypeScript
/**
* @athenna/database
*
* (c) João Lenon <lenon@athenna.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import type { Driver } from '#src/database/drivers/Driver';
import { FakeDriver } from '#src/database/drivers/FakeDriver';
import { MongoDriver } from '#src/database/drivers/MongoDriver';
import { MySqlDriver } from '#src/database/drivers/MySqlDriver';
import { SqliteDriver } from '#src/database/drivers/SqliteDriver';
import { PostgresDriver } from '#src/database/drivers/PostgresDriver';
export declare class ConnectionFactory {
/**
* Holds all the open connections.
*/
static connections: Map<string, any>;
/**
* Holds all the Athenna drivers implementations available.
*/
static drivers: Map<string, any>;
static fabricate(con: 'fake'): typeof FakeDriver;
static fabricate(con: 'mongo'): MongoDriver;
static fabricate(con: 'mysql'): MySqlDriver;
static fabricate(con: 'sqlite'): SqliteDriver;
static fabricate(con: 'postgres'): PostgresDriver;
static fabricate(con: 'fake' | 'mongo' | 'mysql' | 'sqlite' | 'postgres' | string): typeof FakeDriver | MongoDriver | MySqlDriver | SqliteDriver | PostgresDriver;
/**
* Verify if client is present on a driver connection.
*/
static hasClient(con: string): boolean;
/**
* Get client of a connection.
*/
static getClient(con: string): any;
/**
* Set connection client on driver.
*/
static setClient(con: string, client: any): void;
/**
* Return all available drivers.
*/
static availableDrivers(): any[];
/**
* Return all available connections.
*/
static availableConnections(): any[];
/**
* Define your own database driver implementation to use
* within Database facade.
*
* @example
* ```ts
* import { Driver, ConnectionFactory } from '@athenna/database'
*
* class TestDriver extends Driver {}
*
* ConnectionFactory.createDriver('test', TestDriver)
* ```
*/
static createDriver(name: string, impl: typeof Driver<any, any>): void;
/**
* Parse connection config name if is default
*/
private static parseConName;
/**
* Get the connection configuration of config/database file.
*/
private static getConnectionDriver;
}