A class representation of the BSON ObjectId type.

Hierarchy

Constructors

Properties

Mongoose automatically adds a conveniency "_id" getter on the base ObjectId class

cacheHexString: boolean

Accessors

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

  • get id(): Uint8Array
  • The ObjectId bytes

    Returns Uint8Array

Methods

  • Compares the equality of this ObjectId with otherID.

    Parameters

    Returns boolean

  • Returns the generation date (accurate up to the second) that this ID was generated.

    Returns Date

  • Returns string

  • Returns the ObjectId id as a 24 character hex string representation

    Returns string

  • Converts to its JSON the 24 character hex string representation.

    Returns string

  • Converts the id into a 24 character hex string for printing, unless encoding is provided.

    Parameters

    • Optional encoding: "base64" | "hex"

      hex or base64

      Optional

    Returns string

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

    Parameters

    • hexString: string

      create a ObjectId from a passed in 24 character hexstring.

    Returns mongoose.mongo.BSON.ObjectId

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

    Parameters

    • time: number

      an integer number representing a number of seconds.

    Returns mongoose.mongo.BSON.ObjectId

  • Generate a 12 byte id buffer used in ObjectId's

    Parameters

    • Optional time: number

      pass in a second based timestamp.

      Optional

    Returns Uint8Array

  • Checks if a value is a valid bson ObjectId

    Parameters

    Returns boolean

Generated using TypeDoc