Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

Functions

Type aliases

ModelUpdate

ModelUpdate<Model>: object

Type of the data passed to the update function. It extends the model making values optional and allow to set value object.

Type parameters

  • Model

Type declaration

Functions

update

  • update<Model>(collection: Collection<Model>, id: string, data: Field<Model>[]): Promise<void>
  • update<Model>(ref: Ref<Model>, data: Field<Model>[]): Promise<void>
  • update<Model>(collection: Collection<Model>, id: string, data: ModelUpdate<Model>): Promise<void>
  • update<Model>(ref: Ref<Model>, data: ModelUpdate<Model>): Promise<void>
  • Updates a document.

    import { update, field, collection } from 'typesaurus'
    
    type User = {
      name: string,
      address: {
        country: string,
        city: string
      }
    }
    
    const users = collection<User>('users')
    
    update(users, '00sHm46UWKObv2W7XK9e', { name: 'Sasha Koss' })
      .then(() => console.log('Done!'))
    // or using key paths:
    update(users, '00sHm46UWKObv2W7XK9e', [
      field('name', 'Sasha Koss'),
      field(['address', 'city'], 'Moscow')
    ])

    Type parameters

    • Model

    Parameters

    • collection: Collection<Model>

      the collection to update document in

    • id: string

      the id of the document to update

    • data: Field<Model>[]

      the document data to update

    Returns Promise<void>

    A promise that resolves when the operation is finished

  • Updates a document.

    import { update, field, collection } from 'typesaurus'
    
    type User = {
      name: string,
      address: {
        country: string,
        city: string
      }
    }
    
    const users = collection<User>('users')
    
    update(users, '00sHm46UWKObv2W7XK9e', { name: 'Sasha Koss' })
      .then(() => console.log('Done!'))
    // or using key paths:
    update(users, '00sHm46UWKObv2W7XK9e', [
      field('name', 'Sasha Koss'),
      field(['address', 'city'], 'Moscow')
    ])

    Type parameters

    • Model

    Parameters

    • ref: Ref<Model>

      the reference to the document to set

    • data: Field<Model>[]

      the document data to update

    Returns Promise<void>

    A promise that resolves when the operation is finished

  • Updates a document.

    import { update, field, collection } from 'typesaurus'
    
    type User = {
      name: string,
      address: {
        country: string,
        city: string
      }
    }
    
    const users = collection<User>('users')
    
    update(users, '00sHm46UWKObv2W7XK9e', { name: 'Sasha Koss' })
      .then(() => console.log('Done!'))
    // or using key paths:
    update(users, '00sHm46UWKObv2W7XK9e', [
      field('name', 'Sasha Koss'),
      field(['address', 'city'], 'Moscow')
    ])

    Type parameters

    • Model

    Parameters

    • collection: Collection<Model>

      the collection to update document in

    • id: string

      the id of the document to update

    • data: ModelUpdate<Model>

      the document data to update

    Returns Promise<void>

    A promise that resolves when the operation is finished

  • Updates a document.

    import { update, field, collection } from 'typesaurus'
    
    type User = {
      name: string,
      address: {
        country: string,
        city: string
      }
    }
    
    const users = collection<User>('users')
    
    update(users, '00sHm46UWKObv2W7XK9e', { name: 'Sasha Koss' })
      .then(() => console.log('Done!'))
    // or using key paths:
    update(users, '00sHm46UWKObv2W7XK9e', [
      field('name', 'Sasha Koss'),
      field(['address', 'city'], 'Moscow')
    ])

    Type parameters

    • Model

    Parameters

    • ref: Ref<Model>

      the reference to the document to set

    • data: ModelUpdate<Model>

      the document data to update

    Returns Promise<void>

    A promise that resolves when the operation is finished

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