Skip to content

client.dropDatabase()

Oxford Harrison edited this page Nov 15, 2024 · 5 revisions

DOCSAPIClient API


Programmatically perform a DROP DATABASE operation.

See related ➞ DROP DATABASE

Syntax

client.dropDatabase(
    name: string,
    options?: DropOptions
): Promise<DropDatabaseResult>;
Param Interfaces Description
name - An existing database name.
options? DropOptions Optional extra parameters for the query.

DropOptions

type DropOptions = {
    ifExists?: boolean;
    cascade?: boolean;
    restrict?: boolean;
} & QueryOptions;
Param Interfaces Description
ifExists? - (PostgreSQL) An optional flag that adds an EXISTS check to the operation. Defaults to false.
cascade? - (PostgreSQL) An optional flag that adds a CASCADE clause to the operation. Defaults to false.
restrict? - (PostgreSQL) An optional flag that adds a RESTRICT clause to the operation. Defaults to false.
Interface Description
QueryOptions Inherited options.

DropDatabaseResult

type DropDatabaseResult = boolean | DatabaseSchema | Savepoint | null;
Type Interfaces Description
boolean - The boolean true—the default result type for DDL operations without a RETURNING clause.
DatabaseSchema DatabaseSchema For an operation with a RETURNING clause set to SCHEMA-the resulting database schema instance.
Savepoint | null Savepoint For an operation with a RETURNING clause set to SAVEPOINT-the Savepoint instance associated with the DDL operation; null when savepoint creation has been disabled at the server level.

Usage

See examples ➞ DROP DATABASE

Basic call pattern

Drop a database:

await client.dropDatabase(
    'database_1',
    { desc: 'Drop description' }
);
Clone this wiki locally