lakutata
Version:
An IoC-based universal application framework.
101 lines (97 loc) • 2.65 kB
TypeScript
import { BaseDataSourceOptions } from './TypeDef.internal.33.js';
import { ReplicationMode } from './TypeDef.internal.44.js';
import { TlsOptions } from 'tls';
/**
* Cockroachdb specific connection credential options.
*/
interface CockroachConnectionCredentialsOptions {
/**
* Connection url where the connection is performed.
*/
readonly url?: string;
/**
* Database host.
*/
readonly host?: string;
/**
* Database host port.
*/
readonly port?: number;
/**
* Database username.
*/
readonly username?: string;
/**
* Database password.
*/
readonly password?: string;
/**
* Database name to connect to.
*/
readonly database?: string;
/**
* Object with ssl parameters
*/
readonly ssl?: boolean | TlsOptions;
}
/**
* Cockroachdb-specific connection options.
*/
interface CockroachConnectionOptions extends BaseDataSourceOptions, CockroachConnectionCredentialsOptions {
/**
* Database type.
*/
readonly type: "cockroachdb";
/**
* Enable time travel queries on cockroachdb.
* https://www.cockroachlabs.com/docs/stable/as-of-system-time.html
*/
readonly timeTravelQueries: boolean;
/**
* Schema name.
*/
readonly schema?: string;
/**
* The driver object
* This defaults to `require("pg")`.
*/
readonly driver?: any;
/**
* The driver object
* This defaults to `require("pg-native")`.
*/
readonly nativeDriver?: any;
/**
* Replication setup.
*/
readonly replication?: {
/**
* Master server used by orm to perform writes.
*/
readonly master: CockroachConnectionCredentialsOptions;
/**
* List of read-from servers (slaves).
*/
readonly slaves: CockroachConnectionCredentialsOptions[];
/**
* Default connection pool to use for SELECT queries
* @default "slave"
*/
readonly defaultMode?: ReplicationMode;
};
/**
* sets the application_name var to help db administrators identify
* the service using this connection. Defaults to 'undefined'
*/
readonly applicationName?: string;
/**
* Function handling errors thrown by drivers pool.
* Defaults to logging error with `warn` level.
*/
readonly poolErrorHandler?: (err: any) => any;
/**
* Max number of transaction retries in case of 40001 error.
*/
readonly maxTransactionRetries?: number;
}
export type { CockroachConnectionCredentialsOptions, CockroachConnectionOptions };