ObjectId

smile.json.ObjectId
See theObjectId companion class
object ObjectId

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
ObjectId.type

Members list

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def apply(): ObjectId

Generate a new BSON ObjectId.

Generate a new BSON ObjectId.

Attributes

def apply(id: String): ObjectId

Constructs a BSON ObjectId element from a hexadecimal String representation. Throws an exception if the given argument is not a valid ObjectID.

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.

Attributes

def bytes2hex(bytes: Array[Byte]): String

Byte array to hexadecimal string.

Byte array to hexadecimal string.

Attributes

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

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.

Value parameters

fillOnlyTimestamp

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

Attributes

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.

Attributes

Hexadecimal string to byte array.

Hexadecimal string to byte array.

Attributes

def parse(str: String): Try[ObjectId]

Tries to make a BSON ObjectId element from a hexadecimal String representation.

Tries to make a BSON ObjectId element from a hexadecimal String representation.

Attributes

Concrete fields

val size: Int

ObjectId byte array size

ObjectId byte array size

Attributes