object BSONDocumentHandler
BSONDocumentHandler factories
- Alphabetic
- By Inheritance
- BSONDocumentHandler
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
apply[T](read: (BSONDocument) ⇒ T, write: (T) ⇒ BSONDocument): BSONDocumentHandler[T]
Document handler factory.
Document handler factory.
import reactivemongo.api.bson.{ BSONDocument, BSONDocumentHandler } case class Bar(score: Double) val h: BSONDocumentHandler[Bar] = BSONDocumentHandler[Bar]( read = { doc => Bar(doc.getOrElse[Double]("score", 0D)) }, write = { bar => BSONDocument("score" -> bar.score) })
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
collect[T](read: PartialFunction[BSONValue, T], write: PartialFunction[T, BSONDocument]): BSONDocumentHandler[T]
EXPERIMENTAL: Creates a BSONDocumentHandler based on the given
read
andwrite
functions.EXPERIMENTAL: Creates a BSONDocumentHandler based on the given
read
andwrite
functions.import reactivemongo.api.bson.{ BSONDocumentHandler, BSONDocument } val handler = BSONDocumentHandler.collect[String]( read = { case doc: BSONDocument => doc.getAsOpt[Int]("value").collect { case 0 => "zero" case 1 => "one" } getOrElse "" }, write = { case "zero" => BSONDocument("value" -> 0) case "one" => BSONDocument("value" -> 1) }) handler.readTry(BSONDocument("value" -> 0)) // Success("zero") handler.readOpt(BSONDocument("value" -> 3)) // None (as failed) handler.writeTry("one") // Success(BSONDocument("value" -> 1)) handler.writeOpt("3") // None (as failed)
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
from[T](read: (BSONDocument) ⇒ Try[T], write: (T) ⇒ Try[BSONDocument]): BSONDocumentHandler[T]
Creates a BSONDocumentHandler based on the given safe
read
andwrite
functions.Creates a BSONDocumentHandler based on the given safe
read
andwrite
functions.import scala.util.Success import reactivemongo.api.bson.{ BSONDocument, BSONDocumentHandler } case class Bar(score: Double) val h: BSONDocumentHandler[Bar] = BSONDocumentHandler.from[Bar]( read = _.getAsTry[Double]("score").map(Bar(_)), write = { bar => Success(BSONDocument("score" -> bar.score)) })
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
option[T](read: (BSONValue) ⇒ Option[T], write: (T) ⇒ Option[BSONDocument]): BSONDocumentHandler[T]
Creates a BSONDocumentHandler based on the given
read
andwrite
functions.Creates a BSONDocumentHandler based on the given
read
andwrite
functions.import reactivemongo.api.bson.{ BSONDocumentHandler, BSONDocument } val handler = BSONDocumentHandler.option[String]( read = { case doc: BSONDocument => doc.getAsOpt[Int]("value").collect { case 0 => "zero" case 1 => "one" } case _ => None }, write = { case "zero" => Some(BSONDocument("value" -> 0)) case "one" => Some(BSONDocument("value" -> 1)) case _ => None }) handler.readTry(BSONDocument("value" -> 0)) // Success("zero") handler.readOpt(BSONDocument("value" -> 3)) // None (as failed) handler.writeTry("one") // Success(BSONDocument("value" -> 1)) handler.writeOpt("3") // None (as failed)
-
def
provided[T](implicit reader: BSONDocumentReader[T], writer: BSONDocumentWriter[T]): BSONDocumentHandler[T]
Returns a document handler for a type
T
, provided there are a writer and a reader for it.Returns a document handler for a type
T
, provided there are a writer and a reader for it.import reactivemongo.api.bson.{ BSONDocumentHandler, BSONDocumentReader, BSONDocumentWriter } def foo[T]( implicit r: BSONDocumentReader[T], w: BSONDocumentWriter[T]): BSONDocumentHandler[T] = BSONDocumentHandler.provided[T]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()