Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

AddValue

AddValue<T>: T extends Date ? ValueServerDate : never

The value types to use for add operation.

Type parameters

  • T

AnyUpdateValue

AnyUpdateValue: ValueRemove

The value types that have no type constraints.

SetValue

SetValue<T>: T extends Date ? ValueServerDate : never

The value types to use for set operation.

Type parameters

  • T

UpdateValue

UpdateValue<T>: T extends number ? AnyUpdateValue | ValueIncrement : T extends Array<any> ? AnyUpdateValue | ValueArrayUnion | ValueArrayRemove : T extends Date ? ValueServerDate | AnyUpdateValue : AnyUpdateValue

The value types to use for update operation.

Type parameters

  • T

UpsetValue

UpsetValue<T>: T extends number ? ValueIncrement : T extends Array<any> ? ValueArrayUnion | ValueArrayRemove : T extends Date ? ValueServerDate : never

The value types to use for upset operation.

Type parameters

  • T

ValueArrayRemove

ValueArrayRemove: object

The array remove value type. It holds the data to remove from the target array.

Type declaration

  • __type__: "value"
  • kind: "arrayRemove"
  • values: any[]

ValueArrayUnion

ValueArrayUnion: object

The array union value type. It holds the payload to union.

Type declaration

  • __type__: "value"
  • kind: "arrayUnion"
  • values: any[]

ValueIncrement

ValueIncrement: object

The increment value type. It holds the increment value.

Type declaration

  • __type__: "value"
  • kind: "increment"
  • number: number

ValueKind

ValueKind: "remove" | "increment" | "arrayUnion" | "arrayRemove" | "serverDate"

Available value kinds.

ValueRemove

ValueRemove: object

The remove value type.

Type declaration

  • __type__: "value"
  • kind: "remove"

ValueServerDate

ValueServerDate: object

The server date value type.

Type declaration

  • __type__: "value"
  • kind: "serverDate"

Functions

value

  • Creates a value object.

    import { value, set, update, collection } from 'typesaurus'
    
    type User = {
      name: string,
      friends: number
      interests: string[]
      registrationDate: Date
      note?: string
    }
    
    const users = collection<User>('users')
    
    (async () => {
      await set(users, '00sHm46UWKObv2W7XK9e', {
        name: 'Sasha',
        friends: 123,
        interests: ['snowboarding', 'surfboarding', 'running'],
        // Set server date value to the field
        registrationDate: value('serverDate')
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Add 2 to the value
        friends: value('increment', 2),
        // Remove 'running' from the interests
        interests: value('arrayRemove', ['running']),
        note: 'Demo'
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Remove the field
        note: value('remove')
        // Add values to the interests
        interests: value('arrayUnion', ['skateboarding', 'minecraft'])
      })
    })()

    Parameters

    • kind: "remove"

      The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')

    Returns ValueRemove

  • Creates a value object.

    import { value, set, update, collection } from 'typesaurus'
    
    type User = {
      name: string,
      friends: number
      interests: string[]
      registrationDate: Date
      note?: string
    }
    
    const users = collection<User>('users')
    
    (async () => {
      await set(users, '00sHm46UWKObv2W7XK9e', {
        name: 'Sasha',
        friends: 123,
        interests: ['snowboarding', 'surfboarding', 'running'],
        // Set server date value to the field
        registrationDate: value('serverDate')
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Add 2 to the value
        friends: value('increment', 2),
        // Remove 'running' from the interests
        interests: value('arrayRemove', ['running']),
        note: 'Demo'
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Remove the field
        note: value('remove')
        // Add values to the interests
        interests: value('arrayUnion', ['skateboarding', 'minecraft'])
      })
    })()

    Type parameters

    • T: number

    Parameters

    • kind: "increment"

      The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')

    • number: number

    Returns ValueIncrement

  • Creates a value object.

    import { value, set, update, collection } from 'typesaurus'
    
    type User = {
      name: string,
      friends: number
      interests: string[]
      registrationDate: Date
      note?: string
    }
    
    const users = collection<User>('users')
    
    (async () => {
      await set(users, '00sHm46UWKObv2W7XK9e', {
        name: 'Sasha',
        friends: 123,
        interests: ['snowboarding', 'surfboarding', 'running'],
        // Set server date value to the field
        registrationDate: value('serverDate')
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Add 2 to the value
        friends: value('increment', 2),
        // Remove 'running' from the interests
        interests: value('arrayRemove', ['running']),
        note: 'Demo'
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Remove the field
        note: value('remove')
        // Add values to the interests
        interests: value('arrayUnion', ['skateboarding', 'minecraft'])
      })
    })()

    Type parameters

    • T: Array<any>

    Parameters

    • kind: "arrayUnion"

      The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')

    • payload: any[]

      The payload if required by the kind

    Returns ValueArrayUnion

  • Creates a value object.

    import { value, set, update, collection } from 'typesaurus'
    
    type User = {
      name: string,
      friends: number
      interests: string[]
      registrationDate: Date
      note?: string
    }
    
    const users = collection<User>('users')
    
    (async () => {
      await set(users, '00sHm46UWKObv2W7XK9e', {
        name: 'Sasha',
        friends: 123,
        interests: ['snowboarding', 'surfboarding', 'running'],
        // Set server date value to the field
        registrationDate: value('serverDate')
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Add 2 to the value
        friends: value('increment', 2),
        // Remove 'running' from the interests
        interests: value('arrayRemove', ['running']),
        note: 'Demo'
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Remove the field
        note: value('remove')
        // Add values to the interests
        interests: value('arrayUnion', ['skateboarding', 'minecraft'])
      })
    })()

    Type parameters

    • T: Array<any>

    Parameters

    • kind: "arrayRemove"

      The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')

    • payload: any[]

      The payload if required by the kind

    Returns ValueArrayRemove

  • Creates a value object.

    import { value, set, update, collection } from 'typesaurus'
    
    type User = {
      name: string,
      friends: number
      interests: string[]
      registrationDate: Date
      note?: string
    }
    
    const users = collection<User>('users')
    
    (async () => {
      await set(users, '00sHm46UWKObv2W7XK9e', {
        name: 'Sasha',
        friends: 123,
        interests: ['snowboarding', 'surfboarding', 'running'],
        // Set server date value to the field
        registrationDate: value('serverDate')
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Add 2 to the value
        friends: value('increment', 2),
        // Remove 'running' from the interests
        interests: value('arrayRemove', ['running']),
        note: 'Demo'
      })
    
      await update(users, '00sHm46UWKObv2W7XK9e', {
        // Remove the field
        note: value('remove')
        // Add values to the interests
        interests: value('arrayUnion', ['skateboarding', 'minecraft'])
      })
    })()

    Type parameters

    • T: Date

    Parameters

    • kind: "serverDate"

      The value kind ('remove', 'increment', 'arrayUnion', 'arrayRemove' or 'serverDate')

    Returns ValueServerDate

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