Skip to content

client.dropDatabase()

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

DOCSAPIClient API


Programmatically perform a DROP DATABASE operation.

See ➞ DROP DATABASE

Syntax

client.dropDatabase(
    name: string,
    options?: DropOptions
): Promise<DDLResult>;
Param Interfaces Description
name - An existing database name.
options? DropOptions Optional extra parameters for the query.
Interface Description
DDLResult The result type for DDL operations.

DropOptions

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

Usage

Basic usage

Drop a database:

const savepoint = await client.dropDatabase(
    'database_1',
    { desc: 'Dropping for test purposes' }
);

Force-drop, if exits:

const savepoint = await client.dropDatabase(
    'database_1',
    { desc: 'Dropping for test purposes', ifExists: true, cascade: true }
);
Clone this wiki locally