KeyWriter

reactivemongo.api.bson.KeyWriter
See theKeyWriter companion object
trait KeyWriter[T]

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

final class Foo(val v: String) extends AnyVal

val dict = Map[Foo, Int](
 (new Foo("key") -> 1),
 (new Foo("name") -> 2))

import reactivemongo.api.bson.KeyWriter

implicit def fooKeyWriter: KeyWriter[Foo] =
 KeyWriter[Foo] { foo =>
   "foo:" + foo.v
 }

reactivemongo.api.bson.BSON.writeDocument(dict)
// Success = {'foo:key': 1, 'foo:name': 2}

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Abstract methods

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