Represents a unique identifier for a Document.

Constructors

  • 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 valueis already CBOR encoded. You shouldn't need to ever pass this parameter, it's only used internally for certain edge cases. @param skipValidation Iftrue, skips validation of the passed in value or CBOR. You shouldn't need to ever pass this parameter, it's only used internally for certain edge cases.

    • Optional skipValidation: boolean

    Returns DocumentID

Properties

isValidated: boolean

Returns false if validation has been skipped at construction time, otherwise returns true. This is mostly for internal use only, you shouldn't need this in client code.

Accessors

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

    Returns any

Methods

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

    Parameters

    Returns boolean

  • Returns the base64-encoded CBOR representation of this document ID.

    Returns string

    Deprecated

  • Returns a query compatible 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.toQueryCompatibleString()}`)
    

    Returns string

    Deprecated

    use document IDs in queries by embedding them in the query arguments parameter.

  • Returns a string representation of the receiver.

    If you need a string representation to be used directly in a query, please use toQueryCompatibleString() instead.

    Returns string