Options
All
  • Public
  • Public/Protected
  • All
Menu

Mutable version of DocumentPath allowing you to mutate a document at a specific key path. You don't create a MutableDocumentPath directly but obtain one via the at() method of MutableDocument.

Hierarchy

  • MutableDocumentPath

Index

Properties

mutableDocument: MutableDocument

The (mutable) document this path belongs to.

path: string

The full document path so far.

Methods

  • Returns a new mutable document path instance with the passed in key appended (separated by a dot).

    Parameters

    • keyPathOrIndex: string | number

    Returns MutableDocumentPath

  • Returns a new mutable document path instance with the passed in index appended (wrapped by square brackets). Throws if index is less than 0 or not an integer.

    deprecated

    Use at() instead.

    Parameters

    • index: number

    Returns MutableDocumentPath

  • increment(amount: number): void
  • Increments a counter at the document's key path defined by the receiver. This will only succeed if the value at this key path is a counter, otherwise throws an exception.

    Parameters

    • amount: number

      The amount to increment the counter by. This can be a positive or a negative value.

    Returns void

  • insert(value: any): void
  • Inserts a value into an array at the index defined by this key path. This will only succeed if the value at the last component of this key path is an index and the preceding key path points to an array. Otherwise throws an exception.

    Parameters

    • value: any

      The value to insert into the array.

    Returns void

  • pop(): any
  • Pops a value off the end of an array at the document's key path defined by the receiver. This will only succeed if the value at this key path is an array. Otherwise throws an exception.

    Returns any

    The value popped off from the end of the array.

  • push(value: any): void
  • Pushes a value on to the end of an array at the document's key path defined by the receiver. This will only succeed if the value at this key path is an array. Otherwise throws an exception.

    Parameters

    • value: any

      The value to push on to the array.

    Returns void

  • remove(): void
  • Removes a value at the document's key path defined by the receiver. If removing an index from an array, any subsequent indexes will be shifted left to fill the gap.

    Returns void

  • replaceWithCounter(isDefault?: boolean): void
  • Replaces a value at the document's key path defined by the receiver.

    Parameters

    • Optional isDefault: boolean

      Represents whether or not the value is being replaced with a counter that should serve as a default value. Set this to true if you want to set a default value that you expect to be overwritten by other devices in the network. The default value is false.

    Returns void

  • set(value: any, isDefault?: boolean): void
  • Sets a value at the document's key path defined by the receiver.

    Parameters

    • value: any
    • Optional isDefault: boolean

      Represents whether or not the value should be set as a default value. Set this to true if you want to set a default value that you expect to be overwritten by other devices in the network. The default value is false.

    Returns void

  • value(): any
  • Traverses the document with the key path represented by the receiver and returns the corresponding object or value.

    Returns any