BSONElement

BSONElement factories and utilities.

Companion:
class
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply(name: String, value: BSONValue): BSONElement

Create a new BSONElement.

Create a new BSONElement.

import reactivemongo.api.bson.{ BSONElement, BSONLong }

BSONElement("name", BSONLong(2L))
def apply(_name: String, _value: None.type): ElementProducer

Returns an empty ElementProducer

Returns an empty ElementProducer

def unapply(that: Any): Option[(String, BSONValue)]

Extracts the name and BSONValue if that's a BSONElement.

Extracts the name and BSONValue if that's a BSONElement.

import reactivemongo.api.bson.{ BSONDocument, BSONElement }

def foo(doc: BSONDocument): Unit = doc.elements.foreach {
 case BSONElement(name, bson) =>
   println(s"- " + name + " = " + bson)

 case _ =>
}

Inherited methods

def apply[T](name: String, value: T)(implicit ev: T => Producer[BSONValue]): ElementProducer

Returns a ElementProducer for the given name and value.

Returns a ElementProducer for the given name and value.

import reactivemongo.api.bson.{ BSONElement, ElementProducer }

val e1: ElementProducer = BSONElement("name1", 1) // BSONInteger
val e2 = BSONElement("name2", "foo") // BSONString
Inherited from:
BSONElementLowPriority

Implicits

Inherited implicits

import reactivemongo.api.bson.{ BSONElement, BSONInteger }

val e: BSONElement = "foo" -> BSONInteger(1)
// tuple as BSONElement("foo", BSONInteger(1))
Inherited from:
BSONElementLowPriority