@electric-sql/drivers
Version:
ElectricSQL database drivers.
41 lines (40 loc) • 1.05 kB
TypeScript
import type { Client, QueryConfig, QueryResult, QueryResultRow } from 'pg';
export type Database = Pick<Client, 'host' | 'port' | 'database'> & {
query<R extends QueryResultRow = any, I extends any[] = any[]>(queryConfig: QueryConfig<I>): Promise<Pick<QueryResult<R>, 'rows' | 'rowCount'>>;
};
type StopFn = () => Promise<void>;
type PostgresConfig = {
/**
* The name of the database.
*/
name: string;
/**
* The location where the data should be persisted to.
*/
databaseDir: string;
/**
* Default is 'postgres'.
*/
user?: string;
/**
* Default is 'password'.
*/
password?: string;
/**
* Default is 54321.
*/
port?: number;
/**
* When set to fale, the database will be deleted when the DB is stopped.
* Default is true.
*/
persistent?: boolean;
};
/**
* Creates and opens a DB backed by Postgres
*/
export declare function createEmbeddedPostgres(config: PostgresConfig): Promise<{
db: Database;
stop: StopFn;
}>;
export {};