reactivemongo.api.bson.BSONNumberLike
See theBSONNumberLike companion object
A BSON value that can be seen as a number.
Conversions:
- numeric BSON types (BSONDecimal, BSONDouble, BSONInteger, BSONLong)
- BSON date/time ~> long (BSONDateTime
.value
) - BSON timestamp ~> long (BSONTimestamp.value)
import scala.util.Success
import reactivemongo.api.bson.{ BSONNumberLike, BSONDocument, BSONInteger }
val bi = BSONInteger(1)
assert(bi.asTry[BSONNumberLike].flatMap(_.toLong) == Success(1L))
val doc = BSONDocument("field" -> bi)
assert(doc.getAsTry[BSONNumberLike]("field").
flatMap(_.toDouble) == Success(1D))
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any