A class representation of the BSON UUID type.

Hierarchy (view full)

Constructors

  • Create an UUID type

    Parameters

    • Optional input: string | UUID | Uint8Array

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

    Returns UUID

Properties

_bsontype: "Binary"
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

Accessors

  • get id(): Uint8Array
  • The UUID bytes

    Returns Uint8Array

Methods

  • Compares the equality of this UUID with otherID.

    Parameters

    • otherId: string | UUID | Uint8Array

      UUID instance to compare against.

    Returns boolean

  • Returns string

  • the length of the binary sequence

    Returns number

  • Updates this binary with byte_value.

    Parameters

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

      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: string

    Returns string

  • Returns the value of this binary as a string.

    Parameters

    • Optional asRaw: boolean

      Will skip converting to a string

    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 UUID

  • Generates a populated buffer containing a v4 uuid

    Returns Uint8Array

  • Checks if a value is a valid bson UUID

    Parameters

    • input: string | UUID | Uint8Array

      UUID, string or Buffer to validate.

    Returns boolean

Generated using TypeDoc