Constructs a BSON ObjectId element from a hexadecimal String representation.
Constructs a BSON ObjectId element from a hexadecimal String representation. Throws an exception if the given argument is not a valid ObjectID.
parse(str: String): Try[BSONObjectID]
should be considered instead of this method.
Generates a new BSON ObjectID from the given timestamp in milliseconds.
Generates a new BSON ObjectID from the given timestamp in milliseconds.
+------------------------+------------------------+------------------------+------------------------+ + timestamp (in seconds) + machine identifier + thread identifier + increment + + (4 bytes) + (3 bytes) + (2 bytes) + (3 bytes) + +------------------------+------------------------+------------------------+------------------------+
The included timestamp is the number of seconds since epoch, so a BSONObjectID time part has only
a precision up to the second. To get a reasonably unique ID, you _must_ set onlyTimestamp
to false.
Crafting a BSONObjectID from a timestamp with fillOnlyTimestamp
set to true is helpful for range queries,
eg if you want of find documents an _id field which timestamp part is greater than or lesser than
the one of another id.
If you do not intend to use the produced BSONObjectID for range queries, then you'd rather use
the generate
method instead.
if true, the returned BSONObjectID will only have the timestamp bytes set; the other will be set to zero.
Generates a new BSON ObjectID.
Generates a new BSON ObjectID.
+------------------------+------------------------+------------------------+------------------------+ + timestamp (in seconds) + machine identifier + thread identifier + increment + + (4 bytes) + (3 bytes) + (2 bytes) + (3 bytes) + +------------------------+------------------------+------------------------+------------------------+
The returned BSONObjectID contains a timestamp set to the current time (in seconds),
with the machine identifier
, thread identifier
and increment
properly set.
Tries to make a BSON ObjectId element from a hexadecimal String representation.