Ditto JS SDK v5.1.0
    Preparing search index...

    Class QueryResultItem<T>

    Represents a single match of a DQL query, similar to a “row” in SQL terms. It’s a reference type serving as a “cursor”, allowing for efficient access of the underlying data in various formats.

    The value property is lazily materialized and kept in memory until it goes out of scope. To reduce the memory footprint, structure your code such that items can be processed as a stream, i.e. one by one (or in batches) and dematerialize() them right after use.

    Type Parameters

    • T = any

      The type of the item's value.

    Index

    Accessors

    • get isMaterialized(): boolean

      Returns true if value is currently held materialized in memory, otherwise returns false.

      See materialize() and dematerialize().

      Returns boolean

    • get value(): T

      Returns the content as a materialized object.

      The item's value is materialized() on first access and subsequently on each access after performing dematerialize(). Once materialized, the value is kept in memory until explicitly dematerialize()-ed or the item goes out of scope.

      Integer fields with a magnitude of 2^53 or greater are materialized as BigInt, which holds the value exactly — the same value that was stored, with no loss of precision.

      JSON.stringify() throws a TypeError on BigInt. To serialize without losing precision, write each BigInt as a string and restore it with BigInt() when reading it back: JSON.stringify(value, (_key, val) => (typeof val === 'bigint' ? val.toString() : val)). Do not serialize it as a JSON number: JSON.parse() rounds integers with a magnitude of 2^53 or greater to the nearest number, silently losing precision.

      Returns T

    Methods

    • Returns the content of the item as CBOR data.

      Important: The returned CBOR data is not cached, make sure to call this method once and keep it for as long as needed.

      Returns Uint8Array

    • Releases the materialized value from memory. No-op if item is not materialized.

      Returns void

    • Returns the content of the item as a JSON string.

      The string is produced directly from the underlying data, so 64-bit integers appear as exact JSON numbers. This is not a lossless path back into JavaScript, though: JSON.parse() rounds integers with a magnitude of 2^53 or greater to the nearest number. To preserve the exact value, read it from value as a BigInt instead.

      Important: The returned JSON string is not cached, make sure to call this method once and keep it for as long as needed.

      Returns string

    • Loads the CBOR representation of the item's content, decodes it as an object so it can be accessed via value. Keeps the object in memory until dematerialize() is called. No-op if value is already materialized.

      Returns void