Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

Functions

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 { get, collection } from 'typesaurus'
    
    type User = { name: string }
    const users = collection<User>('users')
    
    get(users, '00sHm46UWKObv2W7XK9e').then(user => {
      console.log(user)
      //=> { __type__: 'doc', data: { name: 'Sasha' }, ... }
    })
    // Or using ref:
    get(currentUser.ref)

    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

  • Retrieves a document from a collection.

    import { get, collection } from 'typesaurus'
    
    type User = { name: string }
    const users = collection<User>('users')
    
    get(users, '00sHm46UWKObv2W7XK9e').then(user => {
      console.log(user)
      //=> { __type__: 'doc', data: { name: 'Sasha' }, ... }
    })
    // Or using ref:
    get(currentUser.ref)

    Type parameters

    • Model

    Parameters

    • collection: Collection<Model>

      The collection to get document from

    • id: string

      The document id

    Returns Promise<Doc<Model> | null>

    Promise to the document or null if not found

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