sqlite3orm
Version:
ORM for sqlite3 and TypeScript/JavaScript
62 lines (61 loc) • 1.99 kB
TypeScript
import { SqlDatabase } from './SqlDatabase';
import { SqlDatabaseSettings } from './SqlDatabaseSettings';
/**
* A simple connection pool
*
* @export
* @class SqlConnectionPool
*/
export declare class SqlConnectionPool {
readonly name: string;
private databaseFile?;
private mode;
private min;
private max;
private readonly inPool;
private readonly inUse;
private settings?;
private _opening?;
get poolSize(): number;
get openSize(): number;
/**
* Creates an instance of SqlConnectionPool.
*/
constructor(name?: string);
/**
* Open a database connection pool
*
* @param databaseFile - The path to the database file or URI
* @param [mode=SQL_OPEN_DEFAULT] - A bit flag combination of: SQL_OPEN_CREATE |
* SQL_OPEN_READONLY | SQL_OPEN_READWRITE
* @param [min=1] minimum connections which should be opened by this connection pool
* @param [max=0] maximum connections which can be opened by this connection pool
* @returns A promise
*/
open(databaseFile: string, mode?: number, min?: number, max?: number, settings?: SqlDatabaseSettings): Promise<void>;
protected openInternal(databaseFile: string, mode?: number, min?: number, max?: number, settings?: SqlDatabaseSettings): Promise<void>;
/**
* Close the database connection pool
*
* @returns A promise
*/
close(): Promise<void>;
/**
* test if this connection pool is connected to a database file
*/
isOpen(): boolean;
/**
* get a connection from the pool
*
* @param [timeout=0] The timeout to wait for a connection ( 0 is infinite )
* @returns A promise of the db connection
*/
get(timeout?: number): Promise<SqlDatabase>;
/**
* release a connection to the pool
*
* @param sqldb - The db connection
*/
release(sqldb: SqlDatabase): Promise<void>;
static readonly openNamedPools: Map<string, SqlConnectionPool>;
}