Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UUID

A class representation of the BSON UUID type.

Hierarchy

Index

Constructors

  • new UUID(input?: string | Uint8Array | UUID): UUID
  • Create an UUID type

    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_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 _bsontype(): "Binary"
  • Returns "Binary"

  • get id(): Uint8Array
  • set id(value: Uint8Array): void
  • The UUID bytes

    readonly

    Returns Uint8Array

  • The UUID bytes

    readonly

    Parameters

    • value: Uint8Array

    Returns void

Methods

  • equals(otherId: string | Uint8Array | UUID): boolean
  • Compares the equality of this UUID with otherID.

    Parameters

    • otherId: string | Uint8Array | UUID

      UUID instance to compare against.

    Returns boolean

  • inspect(): string
  • Returns string

  • length(): number
  • the length of the binary sequence

    Returns number

  • put(byteValue: string | number | Uint8Array | number[]): void
  • 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

  • toHexString(includeDashes?: boolean): string
  • 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

  • toJSON(): 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

  • toString(encoding?: "base64" | "hex"): 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 UUID

  • Returns the value of this binary as a string.

    remarks

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

    Parameters

    • Optional asRaw: boolean

      Will skip converting to a string

    Returns string | BinarySequence

  • 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

  • createFromBase64(base64: string): UUID
  • Creates an UUID from a base64 string representation of an UUID.

    Parameters

    • base64: string

    Returns UUID

  • createFromHexString(hexString: string): 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

  • generate(): Uint8Array
  • Generates a populated buffer containing a v4 uuid

    Returns Uint8Array

  • isValid(input: string | Uint8Array | UUID): boolean
  • Checks if a value is a valid bson UUID

    Parameters

    • input: string | Uint8Array | UUID

      UUID, string or Buffer to validate.

    Returns boolean

Generated using TypeDoc