Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObjectId

ObjectId

module

ObjectId

since

0.0.1

author

Eduardo Astolfi eastolfi91@gmail.com

copyright

2016 Eduardo Astolfi eastolfi91@gmail.com

license

MIT Licensed

classdesc

Represents the BSON ObjectId type

param

Can be a 24 byte hex string, a 12 byte binary string or a Number.

Hierarchy

  • ObjectId

Index

Constructors

constructor

  • new ObjectId(id?: string | number): ObjectId

Properties

Private ___id

___id: string

Private _bsontype

_bsontype: string = "ObjectId"

binaryParser

binaryParser: BinaryParser

id

id: string

Protected logger

logger: JSWLogger

Static Private cacheHexString

cacheHexString: string

Static index

index: number = 0

Accessors

generationTime

  • get generationTime(): string | number
  • set generationTime(value: string | number): void

Methods

equals

  • equals(otherID: any): boolean
  • Compares the equality of this ObjectId with [otherID].

    method

    ObjectId#equals

    Parameters

    • otherID: any

      ObjectId instance to compare against.

    Returns boolean

    The result of comparing two ObjectId"s

Private generate

  • generate(time?: string | number): string
  • Generate a 12 byte id string used in ObjectId"s

    method

    ObjectId#generate

    Parameters

    • Optional time: string | number

    Returns string

    The 12 byte id binary string.

Private getInc

  • getInc(): number
  • Update the ObjectId index used in generating new ObjectId"s on the driver

    method

    ObjectId#get_inc

    Returns number

    Next index value.

getTimestamp

  • getTimestamp(): Date
  • Returns the generation time in seconds that this ID was generated.

    method

    ObjectId#getTimestamp

    Returns Date

    Number of seconds in the timestamp part of the 12 byte id.

returnHash

  • returnHash(length: number): string

toHexString

  • toHexString(): string
  • Return the ObjectId id as a 24 byte hex string representation

    method

    ObjectId#toHexString

    Returns string

    The 24 byte hex string representation.

toJSON

  • toJSON(): string

toString

  • toString(): string

Static createFromHexString

  • createFromHexString(hexString: any): ObjectId
  • Creates an ObjectId from a hex string representation of an ObjectId.

    method

    ObjectId#createFromHexString

    Parameters

    • hexString: any

      An ObjectId 24 byte hexstring representation.

    Returns ObjectId

    The created ObjectId

Static createFromTime

  • Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.

    method

    ObjectId#createFromTime

    Parameters

    • time: any

      A number of seconds.

    Returns ObjectId

    The created ObjectId

Static createPk

  • Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.

    method

    ObjectId#createPk

    Returns ObjectId

    return the created ObjectId

Generated using TypeDoc