-
-
Notifications
You must be signed in to change notification settings - Fork 1
savepoint.versionState()
Oxford Harrison edited this page Nov 15, 2024
·
3 revisions
DOCS • API • Savepoint API
Get the Savepoint's version state.
savepoint.versionState(): string;
Savepoints are in the commit
state by default:
// initial creation
const savepoint = await client.createDatabase(
{
name: 'database_1',
tables: [{
name: 'table_1',
columns: [],
}]
},
{ desc: 'Create description', returning: 'savepoint' }
);
console.log(savepoint.versionState()); // "commit"
A rollback sets them to the rollback
state:
// Rollback to version 0
await savepoint.rollback({
desc: 'Changes no more necessary'
});
console.log(savepoint.versionState()); // "rollback"
// Version 0 currently
const savepoint = await client.database('database_1').savepoint({ lookAhead: true });
console.log(savepoint.versionState()); // "rollback"
A recommit (i.e. rollforward) sets them back to the commit
state:
// Rollforward to version 1
await savepoint.recommit({
desc: 'Changes necessary again'
});
console.log(savepoint.versionState()); // "commit"
// Version 1 currently
const savepoint = await client.database('database_1').savepoint();
console.log(savepoint.versionState()); // "commit"