reactivemongo.api.bson.Macros.Annotations
Indicates a BSON reader to be used for a specific property, possibly overriding the default one from the implicit scope.
import reactivemongo.api.bson.{ BSONDocument, BSONDouble, BSONString, BSONReader } import reactivemongo.api.bson.Macros, Macros.Annotations.Reader val scoreReader: BSONReader[Double] = BSONReader.collect[Double] { case BSONString(v) => v.toDouble case BSONDouble(b) => b } case class Foo( title: String, @Reader(scoreReader) score: Double) val reader = Macros.reader[Foo] reader.readTry(BSONDocument( "title" -> "Bar", "score" -> "1.23" // accepted by annotated scoreReader )) // Success: Foo(title = "Bar", score = 1.23D)
Indicates a BSON reader to be used for a specific property, possibly overriding the default one from the implicit scope.