Class UUID

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 | UUID

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

    Returns 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_SENSITIVE: 8 = 8

Sensitive 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

Accessors

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

  • get id(): Uint8Array
  • The UUID bytes

    Returns Uint8Array

Methods

  • Compares the equality of this UUID with otherID.

    Parameters

    • otherId: string | Uint8Array | UUID

      UUID instance to compare against.

    Returns boolean

  • Converts to a string representation of this Id.

    Parameters

    • Optional depth: number
    • Optional options: unknown
    • Optional inspect: InspectFn

    Returns string

    return the 36 character hex string representation.

  • 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.

    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"

    Returns string

  • returns a view of the binary value as a Uint8Array

    Returns Uint8Array

  • Writes a buffer to the binary.

    Parameters

    • sequence: 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 base64 string representation of an UUID.

    Parameters

    • base64: string

    Returns UUID

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

    Parameters

    • hexString: string

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

    Returns UUID

  • Generates a populated buffer containing a v4 uuid

    Returns Uint8Array

  • Checks if a value is a valid bson UUID

    Parameters

    • input: string | Uint8Array | Binary | UUID

      UUID, string or Buffer to validate.

    Returns boolean

Generated using TypeDoc