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) .
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' }
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) . 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' }
An empty BSONDocument.
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}
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)
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) .
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' }
EXPERIMENTAL: Creates a new BSONDocument containing the elements deduplicated by name from the given collection (only the last is kept for a same name).
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 }
EXPERIMENTAL: Creates a new BSONDocument containing the elements deduplicated by name from the given collection (only the last is kept for a same name).
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
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] }
BSONDocument factories & utilities.