Object/Trait

reactivemongo.api.bson

BSONDocumentWriter

Related Docs: trait BSONDocumentWriter | package bson

Permalink

object BSONDocumentWriter

BSONDocumentWriter factories.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BSONDocumentWriter
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def apply[T](write: (T) ⇒ BSONDocument): BSONDocumentWriter[T]

    Permalink

    Creates a BSONDocumentWriter based on the given write function.

    Creates a BSONDocumentWriter based on the given write function. This function is called within a scala.util.Try.

    import reactivemongo.api.bson.{ BSONDocument, BSONDocumentWriter }
    
    case class Foo(value: String)
    
    val foo: BSONDocumentWriter[Foo] =
      BSONDocumentWriter { f: Foo => BSONDocument("value" -> f.value) }
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def collect[T](write: PartialFunction[T, BSONDocument]): BSONDocumentWriter[T]

    Permalink

    Creates a BSONDocumentWriter based on the given partial function.

    Creates a BSONDocumentWriter based on the given partial function.

    A exceptions.ValueDoesNotMatchException is returned as Failure for any value that is not matched by the write function.

    import reactivemongo.api.bson.{ BSONDocument, BSONDocumentWriter }
    
    case class Foo(value: String)
    
    val writer = BSONDocumentWriter.collect[Foo] {
      case Foo(value) if value.nonEmpty =>
        BSONDocument("value" -> value)
    }
  8. def collectFrom[T](write: PartialFunction[T, Try[BSONDocument]]): BSONDocumentWriter[T]

    Permalink

    EXPERIMENTAL: Creates a BSONDocumentWriter based on the given partially safe write function.

    EXPERIMENTAL: Creates a BSONDocumentWriter based on the given partially safe write function.

    A exceptions.ValueDoesNotMatchException is returned as Failure for any value that is not matched by the write function.

    import reactivemongo.api.bson.{ BSONDocument, BSONDocumentWriter }
    
    case class Foo(value: String)
    
    val writer = BSONDocumentWriter.collectFrom[Foo] {
      case Foo(value) if value.nonEmpty =>
        scala.util.Success(BSONDocument("value" -> value))
    }
  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def from[T](write: (T) ⇒ Try[BSONDocument]): BSONDocumentWriter[T]

    Permalink

    Creates a BSONDocumentWriter based on the given write safe function.

    Creates a BSONDocumentWriter based on the given write safe function.

    import scala.util.Success
    import reactivemongo.api.bson.{ BSONDocument, BSONDocumentWriter }
    
    case class Foo(value: String)
    
    val writer = BSONDocumentWriter.from[Foo] { foo =>
      Success(BSONDocument("value" -> foo.value))
    }
    write

    the safe function to write T values as BSON

  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. def option[T](write: (T) ⇒ Option[BSONDocument]): BSONDocumentWriter[T]

    Permalink

    Creates a BSONWriter based on the given write function.

    Creates a BSONWriter based on the given write function.

    import reactivemongo.api.bson.{ BSONDocument, BSONDocumentWriter }
    
    case class Foo(value: String)
    
    val writer = BSONDocumentWriter.option[Foo] { foo =>
      Some(BSONDocument("value" -> foo.value))
    }
  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  21. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  22. def tuple2[A, B](field1: String, field2: String)(implicit arg0: BSONWriter[A], arg1: BSONWriter[B]): BSONDocumentWriter[(A, B)]

    Permalink

    EXPERIMENTAL: Creates a BSONDocumentWriter that writes tuple elements as BSONDocument fields.

    EXPERIMENTAL: Creates a BSONDocumentWriter that writes tuple elements as BSONDocument fields.

    import reactivemongo.api.bson.BSONDocumentWriter
    
    val writer = BSONDocumentWriter.tuple2[String, Int]("name", "age")
    
    writer.writeTry("Foo" -> 20)
    // => Success: {'name': 'Foo', 'age': 20}
  23. def tuple3[A, B, C](field1: String, field2: String, field3: String)(implicit arg0: BSONWriter[A], arg1: BSONWriter[B], arg2: BSONWriter[C]): BSONDocumentWriter[(A, B, C)]

    Permalink

    EXPERIMENTAL: Creates a BSONDocumentWriter that writes tuple elements as BSONDocument fields.

  24. def tuple4[A, B, C, D](field1: String, field2: String, field3: String, field4: String)(implicit arg0: BSONWriter[A], arg1: BSONWriter[B], arg2: BSONWriter[C], arg3: BSONWriter[D]): BSONDocumentWriter[(A, B, C, D)]

    Permalink

    EXPERIMENTAL: Creates a BSONDocumentWriter that writes tuple elements as BSONDocument fields.

  25. def tuple5[A, B, C, D, E](field1: String, field2: String, field3: String, field4: String, field5: String)(implicit arg0: BSONWriter[A], arg1: BSONWriter[B], arg2: BSONWriter[C], arg3: BSONWriter[D], arg4: BSONWriter[E]): BSONDocumentWriter[(A, B, C, D, E)]

    Permalink

    EXPERIMENTAL: Creates a BSONDocumentWriter that writes tuple elements as BSONDocument fields.

  26. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped