reactivemongo.api.bson.Macros.Annotations
Indicates a BSON writer to be used for a specific property, possibly overriding the default one from the implicit scope.
import reactivemongo.api.bson.{ BSONString, BSONWriter } import reactivemongo.api.bson.Macros, Macros.Annotations.Writer val scoreWriter: BSONWriter[Double] = BSONWriter[Double] { d => BSONString(d.toString) // write double as string } case class Foo( title: String, @Writer(scoreWriter) score: Double) val writer = Macros.writer[Foo] writer.writeTry(Foo(title = "Bar", score = 1.23D)) // Success: BSONDocument("title" -> "Bar", "score" -> "1.23")
Indicates a BSON writer to be used for a specific property, possibly overriding the default one from the implicit scope.