A class representation of the BSON UUID type.

Hierarchy

Constructors

  • Create a UUID type

    When the argument to the constructor is omitted a random v4 UUID will be generated.

    Parameters

    • Optional input: string | Uint8Array | mongoose.mongo.BSON.UUID

      Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer.

      Optional

    Returns mongoose.mongo.BSON.UUID

Properties

buffer: Uint8Array
position: number
sub_type: number
BUFFER_SIZE: 256 = 256

Initial buffer default size

SUBTYPE_BYTE_ARRAY: 2 = 2

Byte Array BSON type

SUBTYPE_COLUMN: 7 = 7

Column BSON type

SUBTYPE_DEFAULT: 0 = 0

Default BSON type

SUBTYPE_ENCRYPTED: 6 = 6

Encrypted BSON type

SUBTYPE_FUNCTION: 1 = 1

Function BSON type

SUBTYPE_MD5: 5 = 5

MD5 BSON type

SUBTYPE_USER_DEFINED: 128 = 128

User BSON type

SUBTYPE_UUID: 4 = 4

UUID BSON type

SUBTYPE_UUID_OLD: 3 = 3

Deprecated UUID BSON type

Deprecated

Please use SUBTYPE_UUID

cacheHexString: boolean

Deprecated

Hex string is no longer cached, this control will be removed in a future major release

Accessors

  • get _bsontype(): "Binary"
  • Returns "Binary"

  • get id(): Uint8Array
  • The UUID bytes

    Returns Uint8Array

Methods

  • Compares the equality of this UUID with otherID.

    Parameters

    Returns boolean

  • Returns string

  • the length of the binary sequence

    Returns number

  • Updates this binary with byte_value.

    Parameters

    • byteValue: string | number | Uint8Array | number[]

      a single byte we wish to write.

    Returns void

  • Reads length bytes starting at position.

    Parameters

    • position: number

      read from the given position in the Binary.

    • length: number

      the number of bytes to read.

    Returns BinarySequence

  • Creates a Binary instance from the current UUID.

    Returns Binary

  • Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated)

    Parameters

    • Optional includeDashes: boolean

      should the string exclude dash-separators.

      Optional

    Returns string

  • Converts the id into its JSON string representation. A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

    Returns string

  • Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified.

    Parameters

    • Optional encoding: "base64" | "hex"
      Optional

    Returns string

  • Returns the value of this binary as a string.

    Parameters

    • Optional asRaw: boolean

      Will skip converting to a string

      Optional

    Returns string | BinarySequence

    Remarks

    This is handy when calling this function conditionally for some key value pairs and not others

  • Writes a buffer or string to the binary.

    Parameters

    • sequence: string | BinarySequence

      a string or buffer to be written to the Binary BSON object.

    • offset: number

      specify the binary of where to write the content.

    Returns void

  • Creates an UUID from a hex string representation of an UUID.

    Parameters

    • hexString: string

      32 or 36 character hex string (dashes excluded/included).

    Returns mongoose.mongo.BSON.UUID

  • Generates a populated buffer containing a v4 uuid

    Returns Uint8Array

  • Checks if a value is a valid bson UUID

    Parameters

    Returns boolean

Generated using TypeDoc