publicObjectId
Hierarchy
- BSONValue
- ObjectId
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Create an ObjectId type
Parameters
optionalinputId: string | number | Uint8Array | ObjectId | ObjectIdLike
Can be a 24 character hex string, 12 byte binary Buffer, or a number.
Returns ObjectId
Properties
staticcacheHexString
Accessors
_bsontype
Returns ObjectId
id
The ObjectId bytes
Returns Uint8Array
Methods
equals
Compares the equality of this ObjectId with
otherID
.Parameters
otherId: string | ObjectId | ObjectIdLike
ObjectId instance to compare against.
Returns boolean
getTimestamp
Returns the generation date (accurate up to the second) that this ID was generated.
Returns Date
inspect
Returns string
toHexString
Returns the ObjectId id as a 24 character hex string representation
Returns string
toJSON
Converts to its JSON the 24 character hex string representation.
Returns string
toString
Converts the id into a 24 character hex string for printing, unless encoding is provided.
Parameters
optionalencoding: hex | base64
hex or base64
Returns string
staticcreateFromBase64
Creates an ObjectId instance from a base64 string
Parameters
base64: string
Returns ObjectId
staticcreateFromHexString
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 ObjectId
staticcreateFromTime
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 ObjectId
staticgenerate
Generate a 12 byte id buffer used in ObjectId's
Parameters
optionaltime: number
pass in a second based timestamp.
Returns Uint8Array
staticisValid
Checks if a value is a valid bson ObjectId
Parameters
id: string | number | Uint8Array | ObjectId | ObjectIdLike
ObjectId instance to validate.
Returns boolean
A class representation of the BSON ObjectId type.