Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

TransactionReadFunction

TransactionReadFunction<ReadResult>: function

The transaction body function type.

Type parameters

  • ReadResult

Type declaration

TransactionWriteFunction

TransactionWriteFunction<ReadResult, WriteResult>: function

The transaction body function type.

Type parameters

  • ReadResult

  • WriteResult

Type declaration

Functions

transaction

  • The function allows performing transactions. It accepts two functions. The first receives transaction read API that allows getting data from the database and pass it to the second function. The second function gets transaction write API with the data returned from the first function as data property of the argument.

    import { transaction, collection } from 'typesaurus'
    
    type Counter = { count: number }
    const counters = collection<Counter>('counters')
    
    transaction(
      ({ get }) => get('420'),
      ({ data: counter, update }) =>
        update(counter.ref, { count: counter.data.count + 1 })
    )

    Type parameters

    • ReadResult

    • WriteResult

    Parameters

    • readFunction: TransactionReadFunction<ReadResult>

      the transaction read function that accepts transaction read API and returns data for write function

    • writeFunction: TransactionWriteFunction<ReadResult, WriteResult>

      the transaction write function that accepts transaction write API with the data returned by the read function

    Returns Promise<WriteResult>

    Promise that is resolved when transaction is closed

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc