Options
All
  • Public
  • Public/Protected
  • All
Menu

The transaction read API object. It contains get the function that allows reading documents from the database.

Hierarchy

  • TransactionRead

Index

Methods

Methods

get

  • get<Model>(ref: Ref<Model>): Promise<Doc<Model> | null>
  • get<Model>(collection: Collection<Model>, id: string): Promise<Doc<Model> | null>
  • Retrieves a document from a collection.

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

    Type parameters

    • Model

    Parameters

    • ref: Ref<Model>

      The reference to the document

    Returns Promise<Doc<Model> | null>

    Promise to the document or null if not found

  • Type parameters

    • Model

    Parameters

    • collection: Collection<Model>

      The collection to get document from

    • id: string

      The document id

    Returns Promise<Doc<Model> | null>

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