Skip to content

savepoint.versionTag()

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

DOCSAPISavepoint API


Get the Savepoint's version tag.

See related ➞ savepoint.versionTags()

Syntax

savepoint.versionTag(): number;

Usage

A database's life starts at version 1:

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

Subsequent alterations increment the version:

// Version 2
const savepoint = await client.database('database_1').createTable(
    {
        name: 'table_2',
        columns: [],
    },
    { desc: 'Create description', returning: 'savepoint' }
);
console.log(savepoint.versionTag()); // 2
// Version 2 currently
const savepoint = await client.database('database_1').savepoint();
console.log(savepoint.versionTag()); // 2
Clone this wiki locally