@compas/store
Version:
Postgres & S3-compatible wrappers for common things
42 lines (41 loc) • 1.65 kB
TypeScript
/**
* @param {import("postgres").Options|undefined} opts
* @returns {import("postgres").Options}
*/
export function buildAndCheckOpts(opts: postgres.Options<any> | undefined): postgres.Options<any>;
/**
* Create a new postgres connection, using the default environment variables.
* A database may be created using the provided credentials.
*
* Note that by default we add a 'dateOrTimeOnly' type, which serializes and parses
* 'date' and 'time' columns, used by `T.date().timeOnly()` and `T.date().dateOnly()', as
* strings.
*
* With `createIfNotExists`, Compas will try to connect to Postgres and first check if
* the database exists before establishing the requested connection. Postgres will
* default to connect to a database with the same name as the provided user, but you can
* manually specify the 'maintenanceDatabase' for the temporary connection.
*
* @since 0.1.0
*
* @param {import("postgres").Options & {
* createIfNotExists?: boolean,
* maintenanceDatabaase?: string,
* }} [opts]
* @returns {Promise<import("postgres").Sql<{}>>}
*/
export function newPostgresConnection(opts?: postgres.Options<any> & {
createIfNotExists?: boolean;
maintenanceDatabaase?: string;
}): Promise<import("postgres").Sql<{}>>;
/**
* @param sql
* @param databaseName
* @param maintenanceDatabase
* @param template
* @param connectionOptions
* @returns {Promise<import("postgres").Sql<{}>>}
*/
export function createDatabaseIfNotExists(sql: any, databaseName: any, maintenanceDatabase: any, template: any, connectionOptions: any): Promise<import("postgres").Sql<{}>>;
export { postgres };
import postgres from "postgres";