Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

Functions

add

  • add<Model>(collection: Collection<Model>, data: Model): Promise<Doc<Model>>
  • Adds a new document with a random id to a collection.

    import { add, collection } from 'typesaurus'
    
    type User = { name: string }
    const users = collection<User>('users')
    
    add(users, { name: 'Sasha' }).then(sasha => {
      console.log(sasha.ref.id)
      //=> '00sHm46UWKObv2W7XK9e'
      console.log(sasha.data)
      //=> { name: 'Sasha' }
    })

    Type parameters

    • Model

    Parameters

    • collection: Collection<Model>

      The collection to add to

    • data: Model

      The data to add to

    Returns Promise<Doc<Model>>

    A promise to the 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