const classafBson::ObjectId
sys::Obj afBson::ObjectId
@Serializable { simple=true }
(BSON Type) - A globally unique identifier for MongoDB objects.
Consists of 12 bytes, divided as follows:
| 0 1 2 3 | 4 5 6 | 7 8 | 9 10 11 | timestamp | machine | pid | inc
@See
- fromStr
static new fromStr(Str hex, Bool checked := true)Create an
ObjectIdfrom a hex string.- fromStream
static new fromStream(InStream in)Reads an
ObjectIdfrom the given stream.Note the stream is not closed.
- inc
const Int incA 3-byte
incvalue.- machine
const Int machineA 4-byte machine identifier, usually the IP address.
- make
new make()Creates a new
ObjectId.- pid
const Int pidA 2-byte process id that this instance was created under.
- timestamp
const DateTime timestampThe creation timestamp with a 1 second accuracy.
- toBuf
Buf toBuf()Encodes this
ObjectIdinto an 12 byte buffer. The returned buffer is positioned at the start and is ready to read.- toHex
Str toHex()Converts this instance into a 24 character hexadecimal string representation.
- toJs
Str toJs()Returns a Mongo Shell compliant, JavaScript representation of the
ObjectId. Example:objectId.toJs
// --> ObjectId("57fe499fa81320d933000001")- toStr
virtual override Str toStr()Returns this
ObjectIdas a 24 character hexadecimal string.