Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

Functions

Type aliases

FirebaseQuery

FirebaseQuery: CollectionReference | Query

Query

Query<Model, Key>: OrderQuery<Model, Key> | WhereQuery<Model> | LimitQuery

The query type.

Type parameters

  • Model

  • Key: keyof Model

Functions

onQuery

  • onQuery<Model>(collection: Collection<Model> | CollectionGroup<Model>, queries: Query<Model, keyof Model>[], onResult: function, onError?: undefined | function): function
  • Subscribes to a collection query built using query objects ({@link order | order}, {@link where | where}, {@link limit | limit}).

    import { query, limit, order, startAfter, collection } from 'typesaurus'
    
    type Contact = { name: string; year: number }
    const contacts = collection<Contact>('contacts')
    
    onQuery(contacts, [
      order('year', 'asc', [startAfter(2000)]),
      limit(2)
    ], bornAfter2000 => {
      console.log(bornAfter2000)
      //=> 420
      console.log(bornAfter2000[0].ref.id)
      //=> '00sHm46UWKObv2W7XK9e'
      console.log(bornAfter2000[0].data)
      //=> { name: 'Sasha' }
    })

    Type parameters

    • Model

    Parameters

    • collection: Collection<Model> | CollectionGroup<Model>

      The collection or collection group to query

    • queries: Query<Model, keyof Model>[]

      The query objects

    • onResult: function

      The function which is called with the query result when the initial fetch is resolved or the query result updates.

        • (docs: Doc<Model>[]): any
        • Parameters

          • docs: Doc<Model>[]

          Returns any

    • Optional onError: undefined | function

      The function is called with error when request fails.

    Returns function

    Function that unsubscribes the listener from the updates

      • (): void
      • Returns void

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