BSONObjectID

BSONObjectID utilities

Companion:
class
class Object
trait Matchable
class Any

Value members

Concrete methods

def fromTime(timeMillis: Long, fillOnlyTimestamp: Boolean): BSONObjectID

Generates a new BSON ObjectID from the given timestamp in milliseconds.

Generates a new BSON ObjectID from the given timestamp in milliseconds.

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 an ID from a timestamp with fillOnlyTimestamp set to true is helpful for range queries; e.g 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.

Value parameters:
fillOnlyTimestamp

if true, the returned BSONObjectID will only have the timestamp bytes set; the other will be set to zero.

Generates a new BSON ObjectID using the current time as seed.

Generates a new BSON ObjectID using the current time as seed.

See also:

Tries to make a BSON ObjectId from a hexadecimal string representation.

Tries to make a BSON ObjectId from a hexadecimal string representation.

Tries to make a BSON ObjectId from a binary representation.

Tries to make a BSON ObjectId from a binary representation.

Returns the string representation for the given BSONObjectID.

Returns the string representation for the given BSONObjectID.

def unapply(that: Any): Option[Array[Byte]]

Extracts the bytes if that's a BSONObjectID.

Extracts the bytes if that's a BSONObjectID.