Class MutableDocumentPath

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 path property or the at() method of MutableDocument.

Hierarchy

  • MutableDocumentPath

Properties

mutableDocument: MutableDocument

The (mutable) document this path belongs to.

path: string

The full document path so far.

Accessors

  • get rga(): MutableRGA
  • Returns the value at the previously specified key in the document as a MutableRGA if possible, otherwise returns null.

    @deprecated: RGA usage should be replaced. Use arrays inside Registers instead.

    Returns MutableRGA

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

    Returns any

Methods

  • Returns a new mutable document path instance with the passed in key-path or index appended.

    A key-path can be a single property name or multiple property names separated by a dot. Indexes can also be specified as part of the key path using square brackets syntax. The empty string returns a document path representing the same portion of the document as the receiver. If a key path starts with a property name and is prefixed by a dot, the dot is ignored.

    Examples:

    • mutableDocumentPath.at('mileage')
    • mutableDocumentPath.at('driver.name')
    • mutableDocumentPath.at('passengers[2]')
    • mutableDocumentPath.at('passengers[2].belongings[1].kind')
    • mutableDocumentPath.at('.mileage')

    Parameters

    • keyPathOrIndex: string | number

    Returns MutableDocumentPath

  • Removes a value at the document's key-path defined by the receiver. If removing an index from an RGA, any subsequent indexes will be shifted left to fill the gap.

    Returns 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