-
-
Notifications
You must be signed in to change notification settings - Fork 2
savepoint.rollback()
Oxford Harrison edited this page Nov 15, 2024
·
5 revisions
DOCS • API • Savepoint API
Perform a rollback.
See related ➞
savepoint.recommit()
savepoint.rollback(
options?: RollbackOptions
): Promise<boolean>;
Param | Interfaces | Description |
---|---|---|
options? |
RollbackOptions |
Optional extra parameters for the operation. |
type RollbackOptions = {
desc?: string;
};
Param | Interfaces | Description |
---|---|---|
desc? |
- | A string description of the rollback operation. Required if the Linked DB's config.require_commit_descs is active. |
Create savepoints:
// Perform a DDL operation and obtain savepoint (1)
const savepoint1 = await client.createDatabase(
{
name: 'database_1',
tables: [{
name: 'table_1',
columns: [],
}]
},
{ desc: 'Create description', returning: 'savepoint' }
);
// Perform a DDL operation and obtain savepoint (2)
const savepoint2 = await client.database('database_1').createTable(
{
name: 'table_2',
columns: [],
},
{ desc: 'Create description', returning: 'savepoint' }
);
Rollback all changes (latest-first):
// Rollback to version 1 (drops table)
await savepoint2.rollback({
desc: 'Changes no more necessary'
});
// Rollback to version 0 (drops database)
await savepoint1.rollback({
desc: 'Changes no more necessary'
});