KeyReader

reactivemongo.api.bson.KeyReader
See theKeyReader companion object
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))

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Abstract methods

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