KeyReader

trait KeyReader[T]

Mapping from a BSON string to T; Used by scala.collection.Map handlers.

final class Foo(val v: String) extends AnyVal

val bson = reactivemongo.api.bson.BSONDocument(
 "foo:key" -> 1, "foo:name" -> 2)

import reactivemongo.api.bson.KeyReader

implicit def fooKeyReader: KeyReader[Foo] =
 KeyReader[Foo] { str =>
   new Foo(str.stripPrefix("foo:"))
 }

reactivemongo.api.bson.BSON.readDocument[Map[Foo, Int]](bson)
// Success: Map[Foo, Int](
//  (new Foo("key") -> 1),
//  (new Foo("name") -> 2))
Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def readTry(key: String): Try[T]