Skip to content
Oxford Harrison edited this page Nov 15, 2024 · 2 revisions

DOCSAPISavepoint API


Get the Savepoint's database name.

Syntax

savepoint.count(
    postRestore?: boolean,
): string;
Param Interfaces Description
postRestore? - Optional directive that get's the database's post-restore name returned, instead of it's pre-restore name. Useful for working with Savepoints with database renames.

Usage

Given the following operation:

// Name change
const savepoint = await client.alterDatabase(
    'database_1',
    (schema) => schema.name('database_1_new'),
    { returning: 'savepoint' }
);

Get the database's pre- and post-restore names:

// The database's active, pre-restore name
console.log(savepoint.name()); // database_1_new
// The database's post-restore name
console.log(savepoint.name(true)); // database_1

Given the following rollback:

const savepoint = await savepoint.rollback();

Get the database's pre- and post-restore names:

// The database's active, pre-restore name
console.log(savepoint.name()); // database_1
// The database's post-restore name
console.log(savepoint.name(true)); // database_1_new
Clone this wiki locally