BSONDocument

reactivemongo.api.bson.BSONDocument$
See theBSONDocument companion class

BSONDocument factories & utilities.

reactivemongo.api.bson.BSONDocument("foo" -> 1, "bar" -> "lorem")

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Type members

Types

'''EXPERIMENTAL'''

'''EXPERIMENTAL'''

Attributes

Value members

Concrete methods

Creates a new BSONDocument containing the unique elements from the given collection (only one instance of a same element, same name & value, is kept) . In case of conversion error for a field value, the field is ignored.

Creates a new BSONDocument containing the unique elements from the given collection (only one instance of a same element, same name & value, is kept) . In case of conversion error for a field value, the field is ignored.

reactivemongo.api.bson.BSONDocument(
 "foo" -> 1, "bar" -> "lorem"
) // => { 'foo': 1, 'bar': 'lorem' }

Attributes

Creates a new BSONDocument containing the unique elements from the given collection (only one instance of a same element, same name & value, is kept) .

Creates a new BSONDocument containing the unique elements from the given collection (only one instance of a same element, same name & value, is kept) .

import reactivemongo.api.bson._

BSONDocument(Seq(
 "foo" -> BSONInteger(1), "bar" -> BSONString("lorem")))
// { 'foo': 1, 'bar': 'lorem' }

Attributes

'''EXPERIMENTAL:''' Returns a BSONDocument builder.

'''EXPERIMENTAL:''' Returns a BSONDocument builder.

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

val builder = BSONDocument.newBuilder

builder += ("foo" -> 1)
builder ++= Seq("bar" -> "lorem", "ipsum" -> 3.45D)
builder ++= Some[ElementProducer]("dolor" -> 6L)

// builder.result() == {'foo':1, 'bar':'lorem', 'ipsum':3.45, 'dolor':6}

Attributes

Returns a String representing the given BSONDocument.

Returns a String representing the given BSONDocument.

import reactivemongo.api.bson.BSONDocument

def printDoc(doc: BSONDocument): String = BSONDocument.pretty(doc)

Attributes

See also:

'''EXPERIMENTAL:''' Creates a new BSONDocument containing the unique elements from the given collection (only one instance of a same element, same name & value, is kept) . Fails if any error occurs while converting the field values.

'''EXPERIMENTAL:''' Creates a new BSONDocument containing the unique elements from the given collection (only one instance of a same element, same name & value, is kept) . Fails if any error occurs while converting the field values.

reactivemongo.api.bson.BSONDocument.safe(
 "foo" -> 1, "bar" -> "lorem"
) // => Success: { 'foo': 1, 'bar': 'lorem' }

Attributes

'''EXPERIMENTAL:''' Creates a new BSONDocument containing the elements deduplicated by name from the given collection (only the last is kept for a same name). Then append operations on such document will maintain element unicity by field name (see BSONStrictDocument.++).

'''EXPERIMENTAL:''' Creates a new BSONDocument containing the elements deduplicated by name from the given collection (only the last is kept for a same name). Then append operations on such document will maintain element unicity by field name (see BSONStrictDocument.++).

reactivemongo.api.bson.BSONDocument("foo" -> 1, "bar" -> 2, "foo" -> 3)
// => { "foo": 1, "bar": 2 } : No "foo": 3

Attributes

'''EXPERIMENTAL:''' Creates a new BSONDocument containing the elements deduplicated by name from the given collection (only the last is kept for a same name). Then append operations on such document will maintain element unicity by field name (see BSONStrictDocument.++).

'''EXPERIMENTAL:''' Creates a new BSONDocument containing the elements deduplicated by name from the given collection (only the last is kept for a same name). Then append operations on such document will maintain element unicity by field name (see BSONStrictDocument.++).

import reactivemongo.api.bson._

BSONDocument.strict(Seq(
 "foo" -> BSONInteger(1), "foo" -> BSONString("lorem")))
// { 'foo': 1 }

Attributes

def unapply(that: Any): Option[Seq[BSONElement]]

Extracts the elements if that's a BSONDocument.

Extracts the elements if that's a BSONDocument.

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

def names(v: BSONValue): Seq[String] = v match {
 case BSONDocument(elements) => elements.map(_.name)
 case _ => Seq.empty[String]
}

Attributes

Concrete fields

An empty BSONDocument.

An empty BSONDocument.

Attributes