Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DocumentID

Represents a unique identifier for a Document.

Hierarchy

  • DocumentID

Index

Constructors

Accessors

Methods

Constructors

constructor

  • new DocumentID(value: any, skipCBOREncoding?: boolean): DocumentID
  • Creates a new DocumentID.

    A document ID can be created from any of the following:

    • string
    • number (integer)
    • boolean
    • null
    • raw data in the form of a JS Typed Array
    • Array (containing any of the items in this list)
    • Map (a raw JS object, where the keys must be strings and the values can be made up of any of the items in this list)

    Note that you cannot use floats or other custom types to create a document ID.

    Document IDs are also limited in size, based on their serialized representation, to 256 bytes. You will receive an error if you try to create a document ID that exceeds the size limit.

    Parameters

    • value: any

      The value that represents the document identifier.

    • Optional skipCBOREncoding: boolean

      If true, skips CBOR encoding and assumes the passed in value` is already CBOR encoded. You shouldn't need to ever pass this parameter, it's only used internally for certain edge cases.

    Returns DocumentID

Accessors

value

  • get value(): any
  • Returns the value of the receiver, lazily decoded from its CBOR representation if needed.

    Returns any

Methods

equals

  • Returns true if passed in documentID is equal to the receiver, otherwise returns false.

    Parameters

    Returns boolean

toString

  • toString(): string
  • Returns a string representation of the receiver.

    The returned string can be used directly in queries that you use with other Ditto functions. For example you could create a query that was like this:

    collection.find(`_id == ${documentID.toString()}`)
    

    Returns string