Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UUID

A class representation of the BSON UUID type.

Hierarchy

  • UUID

Index

Constructors

constructor

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

    Parameters

    • Optional input: string | Buffer | UUID

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

    Returns UUID

Properties

_bsontype

_bsontype: "UUID"

id

id: Buffer

Static cacheHexString

cacheHexString: boolean

Methods

equals

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

    Parameters

    • otherId: string | Buffer | UUID

      UUID instance to compare against.

    Returns boolean

inspect

  • inspect(): string
  • Returns string

toBinary

  • Creates a Binary instance from the current UUID.

    Returns Binary

toHexString

  • 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

Static createFromHexString

  • 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

Static generate

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

    Returns Buffer

Static isValid

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

    Parameters

    • input: string | Buffer | UUID

      UUID, string or Buffer to validate.

    Returns boolean

Generated using TypeDoc