Represents a portion of the document at a specific key-path.

Provides an interface to specify a path to a key in a document that you can then call a function on to get the value at the specified key as a specific type. You don't create a DocumentPath directly but obtain one via the path property or the at() method of Document.

Not available in React Native environments.

Use DQL (Ditto Query Language) instead. For more information see: https://ditto.com/link/dql-legacy-to-dql-adoption

Properties

Accessors

Methods

Properties

document: Document

The document this path belongs to.

Use DQL (Ditto Query Language) instead. For more information see: https://ditto.com/link/dql-legacy-to-dql-adoption

path: string

The full document path so far.

Use DQL (Ditto Query Language) instead. For more information see: https://ditto.com/link/dql-legacy-to-dql-adoption

Accessors

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

    Returns any

    when called in a React Native environment.

    Use DQL (Ditto Query Language) instead. For more information see: https://ditto.com/link/dql-legacy-to-dql-adoption

Methods

  • Returns a new 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 the square bracket 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:

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

    Parameters

    • keyPathOrIndex: string | number

    Returns DocumentPath

    when called in a React Native environment.

    Use DQL (Ditto Query Language) instead. For more information see: https://ditto.com/link/dql-legacy-to-dql-adoption