Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

getRefPath

  • getRefPath(ref: Ref<any>): string
  • Generates Firestore path from a reference.

    Parameters

    • ref: Ref<any>

      The reference to a document

    Returns string

    Firestore path

pathToRef

  • pathToRef<Model>(path: string): Ref<Model>
  • Creates a reference from a Firestore path.

    Type parameters

    • Model

    Parameters

    • path: string

      The Firestore path

    Returns Ref<Model>

    Reference to a document

ref

  • ref<Model>(collection: Collection<Model>, id?: undefined | string): Ref<Model>
  • Creates reference object to a document in given collection with given id.

    import { ref, query, collection, where, Ref } from 'typesaurus'
    
    type User = { name: string }
    type Order = { user: Ref<User>, item: string }
    const users = collection<User>('users')
    const orders = collection<User>('orders')
    
    query(orders, [where('user', '==', ref(users, '00sHm46UWKObv2W7XK9e')])
      .then(userOrders => {
        console.log(userOrders.length)
        //=> 42
      })

    When id param is not passed it will be automatically generated:

    import { ref, set, Ref } from 'typesaurus'
    
    type User = { name: string }
    const users = collection<User>('users')
    
    const id = ref(users).id
    set(users, id, {name: 'John Doe'})

    Type parameters

    • Model

    Parameters

    • collection: Collection<Model>

      The collection to create refernce in

    • Optional id: undefined | string

    Returns Ref<Model>

    The reference object

refToFirestoreDocument

  • refToFirestoreDocument<Model>(ref: Ref<Model>): DocumentReference
  • Creates Firestore document from a reference.

    Type parameters

    • Model

    Parameters

    • ref: Ref<Model>

      The reference to create Firestore document from

    Returns DocumentReference

    Firestore document

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