Skip to main content
Module

x/postgres/mod.ts>Transaction#getSnapshot

PostgreSQL driver for Deno
Extremely Popular
Go to Latest
method Transaction.prototype.getSnapshot
import { Transaction } from "https://deno.land/x/postgres@v0.17.0/mod.ts";

This method returns the snapshot id of the on going transaction, allowing you to share the snapshot state between two transactions

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

const client_1 = new Client();
const client_2 = new Client();
const transaction_1 = client_1.createTransaction("transaction");

const snapshot = await transaction_1.getSnapshot();
const transaction_2 = client_2.createTransaction("new_transaction", { isolation_level: "repeatable_read", snapshot });
// transaction_2 now shares the same starting state that transaction_1 had

https://www.postgresql.org/docs/14/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION

Returns

Promise<string>