BSONObjectID

sealed abstract class BSONObjectID extends BSONValue

BSON ObjectId value.

import scala.util.Try
import reactivemongo.api.bson.BSONObjectID

val oid: BSONObjectID = BSONObjectID.generate()

def foo: Try[BSONObjectID] = BSONObjectID.parse(oid.stringify)
Timestamp (seconds)Machine identifierThread identifierIncrement
4 bytes3 bytes2 bytes3 bytes
Companion:
object
trait BSONValue
class Object
trait Matchable
class Any

Value members

Abstract methods

The time of this BSONObjectId, in seconds

The time of this BSONObjectId, in seconds

Concrete methods

final def byteArray: Array[Byte]

Returns the whole binary content as array.

Returns the whole binary content as array.

override def equals(that: Any): Boolean
Definition Classes
Any
final def time: Long

The time of this BSONObjectId, in milliseconds

The time of this BSONObjectId, in milliseconds

override def toString: String
Definition Classes
Any

Inherited methods

final def asOpt[T](implicit reader: BSONReader[T]): Option[T]

Optionally parses this value as a T one.

Optionally parses this value as a T one.

Returns:

Some successfully parsed value, or None if fails

import reactivemongo.api.bson.BSONValue
def foo(v: BSONValue): Option[String] = v.asOpt[String]
Inherited from:
BSONValue
final def asTry[T](implicit reader: BSONReader[T]): Try[T]

Tries to parse this value as a T one.

Tries to parse this value as a T one.

import scala.util.Try
import reactivemongo.api.bson.BSONValue

def foo(v: BSONValue): Try[String] = v.asTry[String]
Inherited from:
BSONValue

Concrete fields

val code: Int
lazy override val hashCode: Int
lazy val stringify: String

The hexadecimal String representation.

The hexadecimal String representation.

import reactivemongo.api.bson.BSONObjectID

def foo(oid: BSONObjectID): scala.util.Try[BSONObjectID] = {
 val repr: String = oid.stringify
 BSONObjectID.parse(repr)
}