import { Bson } from "https://deno.land/x/mongo@v0.31.2/mod.ts";
const { ObjectId } = Bson;
A class representation of the BSON ObjectId type.
Methods
equals(otherId: string | ObjectId | ObjectIdLike): boolean
Compares the equality of this ObjectId with otherID
.
getTimestamp(): Date
Returns the generation date (accurate up to the second) that this ID was generated.
inspect(): string
toString(encoding?: "hex" | "base64"): string
Converts the id into a 24 character hex string for printing, unless encoding is provided.
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.
isValid(id: ): boolean
| string
| number
| ObjectId
| ObjectIdLike
| Uint8Array
Checks if a value is a valid bson ObjectId