Skip to content

savepoint.isNextRestorePoint()

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

DOCSAPISavepoint API


Check if Savepoint can be restored.

Syntax

savepoint.isNextRestorePoint(): Promise<boolean>;

Usage

Savepoints can be rolled back if they haven't been succeeded by newer savepoints:

// Version 1
const savepoint1 = await client.createDatabase(
    {
        name: 'database_1',
        tables: [{
            name: 'table_1',
            columns: [],
        }]
    },
    { desc: 'Create description', returning: 'savepoint' }
);
console.log(await savepoint1.isNextRestorePoint()); // true

Subsequent alterations have to be rolled back first:

// Version 2
const savepoint2 = await client.database('database_1').createTable(
    {
        name: 'table_2',
        columns: [],
    },
    { desc: 'Create description', returning: 'savepoint' }
);
console.log(await savepoint2.isNextRestorePoint()); // true
console.log(await savepoint1.isNextRestorePoint()); // false
// Rollback to version 1
await savepoint2.rollback({
    desc: 'Changes no more necessary'
});
console.log(await savepoint1.isNextRestorePoint()); // true
Clone this wiki locally