Skip to main content
Module

x/denodb/deps.ts>SQLiteClient#transaction

MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Latest
method SQLiteClient.prototype.transaction
import { SQLiteClient } from "https://deno.land/x/denodb@v1.4.0/deps.ts";

Run a function within the context of a database transaction. If the function throws an error, the transaction is rolled back. Otherwise, the transaction is committed when the function returns.

Calls to transaction may be nested. Nested transactions behave like SQLite save points.

Example

db.transaction(() => {
  // call db.query) ...
  db.transaction(() => {
    // nested transaction
  });
  // throw to roll back everything
});

Parameters

closure: () => V