Skip to main content
The Deno 2 Release Candidate is here
Learn more
Latest
method postgres.Savepoint.prototype.release
import { postgres } from "https://deno.land/x/miranda@0.0.6/src/deps.ts";
const { Savepoint } = postgres;

Releasing a savepoint will remove it's last instance in the transaction

import { Client } from "../client.ts";

const client = new Client();
const transaction = client.createTransaction("transaction");

const savepoint = await transaction.savepoint("n1");
await savepoint.release();
transaction.rollback(savepoint); // Error, can't rollback because the savepoint was released

It will also allow you to set the savepoint to the position it had before the last update

import { Client } from "../client.ts";

const client = new Client();
const transaction = client.createTransaction("transaction");

const savepoint = await transaction.savepoint("n1");
await savepoint.update();
await savepoint.release(); // This drops the update of the last statement
transaction.rollback(savepoint); // Will rollback to the first instance of the savepoint

This function will throw if there are no savepoint instances to drop