1

I am working on upgrading legacy scala DAO layer code from reactivemongo 0.20 to 1.0. The old code return JsObject, compiler is asking for the implicit BSONDocumentReader[JsObject].

However, I can't find any way to define this val from the official document: http://reactivemongo.org/releases/1.0/documentation/json/overview.html

def findOneAsJson(selector: BSONDocument, projection: BSONDocument = BSONDocument(),sort: BSONDocument = BSONDocument()): Future[Option[JsObject]] = {
    implicit val ec = ExecutionContext.global
    collection.flatMap(_.find(selector, Some(projection))
      .sort(sort).one[JsObject])
  }

And directly use macro will introduce more errors, but I can use Macro for any other types expect Json related type:

implicit val reader: BSONDocumentReader[JsObject] =  Macros.reader[JsObject]
code farmer
  • 91
  • 1
  • 8

0 Answers0