Skip to main content
Module

x/kysely_deno_postgres_dialect/mod.ts>postgres.Savepoint#update

Kysely dialect for PostgreSQL using the deno-postgres client.
Latest
method postgres.Savepoint.prototype.update
import { postgres } from "https://deno.land/x/kysely_deno_postgres_dialect@v0.27.1/mod.ts";
const { Savepoint } = postgres;

Updating a savepoint will update its position in the transaction execution

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

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

const my_value = "some value";

const savepoint = await transaction.savepoint("n1");
transaction.queryArray`INSERT INTO MY_TABLE (X) VALUES (${my_value})`;
await savepoint.update(); // Rolling back will now return you to this point on the transaction

You can also undo a savepoint update by using the release method

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

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

const savepoint = await transaction.savepoint("n1");
transaction.queryArray`DELETE FROM VERY_IMPORTANT_TABLE`;
await savepoint.update(); // Oops, shouldn't have updated the savepoint
await savepoint.release(); // This will undo the last update and return the savepoint to the first instance
await transaction.rollback(); // Will rollback before the table was deleted