Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

Functions

Type aliases

UpsetModel

UpsetModel<Model>: object

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

Type parameters

  • Model

Type declaration

Functions

upset

  • upset<Model>(ref: Ref<Model>, data: UpsetModel<Model>): Promise<void>
  • upset<Model>(collection: Collection<Model>, id: string, data: UpsetModel<Model>): Promise<void>
  • Sets a document to the given data or updates if it exists.

    import { upset, update, get, collection } from 'typesaurus'
    
    type User = { name: string, deleted?: boolean }
    const users = collection<User>('users')
    
    const userId = '00sHm46UWKObv2W7XK9e'
    await upset(users, userId, { name: 'Sasha' })
    await update(users, userId, { deleted: true })
    await upset(users, userId, { name: 'Sasha Koss' })
    console.log(await get(users, userId))
    //=> { name: 'Sasha Koss', deleted: true }

    Type parameters

    • Model

    Parameters

    • ref: Ref<Model>

      the reference to the document to set or update

    • data: UpsetModel<Model>

      the document data

    Returns Promise<void>

  • Sets a document to the given data or updates if it exists.

    import { upset, update, get, collection } from 'typesaurus'
    
    type User = { name: string, deleted?: boolean }
    const users = collection<User>('users')
    
    const userId = '00sHm46UWKObv2W7XK9e'
    await upset(users, userId, { name: 'Sasha' })
    await update(users, userId, { deleted: true })
    await upset(users, userId, { name: 'Sasha Koss' })
    console.log(await get(users, userId))
    //=> { name: 'Sasha Koss', deleted: true }

    Type parameters

    • Model

    Parameters

    • collection: Collection<Model>

      the collection to set or update

    • id: string

      the id of the document to set or update

    • data: UpsetModel<Model>

      the document data

    Returns Promise<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