object BSONArray
BSONArray utilities
import reactivemongo.api.bson.{ BSONArray, BSONString }
BSONArray("foo", 1) match {
case BSONArray(BSONString(s) +: _) => s == "foo"
case _ => false
}
- Companion:
- class
Value members
Concrete methods
Creates a new BSONArray containing all the values
.
In case of conversion error for a field value, the field is ignored.
Creates a new BSONArray containing all the values
.
In case of conversion error for a field value, the field is ignored.
reactivemongo.api.bson.BSONArray("foo", 1L)
// [ 'foo', NumberLong(1) ]
Extracts the values sequence if that
's a BSONArray.
Extracts the values sequence if that
's a BSONArray.
import reactivemongo.api.bson.{ BSONArray, BSONValue }
def foo(input: BSONValue): Unit = input match {
case BSONArray(vs) => pretty(vs)
case _ => println("Not a BSON array")
}
def bar(arr: BSONArray): Unit = arr match {
// with splat pattern
case BSONArray(Seq(requiredFirst, other @ _*)) =>
println(s"first = \$requiredFirst")
pretty(other)
case _ =>
println("BSON array doesn't match")
}
def pretty(values: Seq[BSONValue]): Unit =
println(values.map(BSONValue.pretty).mkString(", "))