Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Connection<$$>

Represents a connection to the database.

A connection offers no extra functionality beyond a Transaction, but grouping several transactions together into a single connection will be more efficient than creating a new connection for each transaction.

Type parameters

  • $$

Hierarchy

  • Connection

Index

Properties

Methods

Properties

Readonly $

$: $$

The connection shorthand object.

An operation such as

await conn.$.myStore.add(myitem)

Will add an item to the database store called myStore.

Also see Example.

Methods

close

transact

  • Run a transaction on the connection.

    This will create a new Transaction and run the given callback on it. If The callback completes successfully, the transaction is committed; if the callback throws, then the transaction is aborted.

    Type parameters

    • R

    Parameters

    Returns Promise<R>

wrap

  • wrap<R>(callback: (conn: this) => Promise<R>): Promise<R>
  • Run some code with this connection and then close it afterwards.

    If the code completes successfully, then the transaction will be committed. If the code throws, then the transaction will be aborted.

    Type parameters

    • R

    Parameters

    • callback: (conn: this) => Promise<R>
        • (conn: this): Promise<R>
        • Parameters

          • conn: this

          Returns Promise<R>

    Returns Promise<R>

Generated using TypeDoc