const classafBson::ObjectId
sys::Obj afBson::ObjectId
@Serializable { simple=true }
(BSON Type) - A globally unique identifier for MongoDB objects.
The ObjectID BSON type is a 12-byte value consisting of three different portions (fields):
- a 4-byte value representing the seconds since the Unix epoch in the highest order bytes
- a 5-byte random number unique to a machine and process
- a 3-byte counter, starting with a random value
4 byte timestamp 5 byte process unique 3 byte counter |<----------------->|<---------------------->|<------------>| [----|----|----|----|----|----|----|----|----|----|----|----] 0 4 8 12
@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 counter value.
- make
new make()Creates a new
ObjectId.- pid
const Int pidA 5-byte process id that this instance was created under.
- timestamp
DateTime timestamp(TimeZone tz := TimeZone.cur())Converts the
tsfield into a FantomDateTimeinstance.- 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.- ts
const Int tsThe creation timestamp with a 1 second accuracy.
- writeToStream
OutStream writeToStream(OutStream out)Writes this
ObjectIdto the givenOutStream.