import { mongo } from "https://deno.land/x/hex@0.5.15/src/data/deps.ts";
const { ObjectId } = mongo.Bson;
A class representation of the BSON ObjectId type.
Constructors
Methods
getTimestamp(): Date
Returns the generation date (accurate up to the second) that this ID was generated.
toExtendedJSON(): ObjectIdExtended
toHexString(): string
Returns the ObjectId id as a 24 character hex string representation
toJSON(): string
Converts to its JSON the 24 character hex string representation.
toString(): string
Converts the id into a 24 character hex string for printing
[Symbol.for("Deno.customInspect")](): string
Static Methods
createFromHexString(hexString: string): ObjectId
Creates an ObjectId from a hex string representation of an ObjectId.
createFromTime(time: number): ObjectId
Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.
fromExtendedJSON(doc: ObjectIdExtended): ObjectId
generate(time?: number): Uint8Array
Generate a 12 byte id buffer used in ObjectId's