object BSONDocumentWriter
BSONDocumentWriter factories.
- Alphabetic
- By Inheritance
- BSONDocumentWriter
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
apply[T](write: (T) ⇒ BSONDocument): BSONDocumentWriter[T]
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) }
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
collect[T](write: PartialFunction[T, BSONDocument]): BSONDocumentWriter[T]
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 thewrite
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) }
-
def
collectFrom[T](write: PartialFunction[T, Try[BSONDocument]]): BSONDocumentWriter[T]
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 thewrite
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)) }
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
field[T](name: String)(implicit w: BSONWriter[T]): BSONDocumentWriter[T]
EXPERIMENTAL: Creates a BSONDocumentWriter that writes a single value as a BSONDocument with a single field.
EXPERIMENTAL: Creates a BSONDocumentWriter that writes a single value as a BSONDocument with a single field.
- name
the name of the field to be written
import reactivemongo.api.bson.BSONDocumentWriter val writer = BSONDocumentWriter.field[String]("foo") writer.writeTry("bar") // => Success: {'foo': 'bar'}
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
from[T](write: (T) ⇒ Try[BSONDocument]): BSONDocumentWriter[T]
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
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
option[T](write: (T) ⇒ Option[BSONDocument]): BSONDocumentWriter[T]
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)) }
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
tuple2[A, B](field1: String, field2: String)(implicit arg0: BSONWriter[A], arg1: BSONWriter[B]): BSONDocumentWriter[(A, B)]
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}
-
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)]
EXPERIMENTAL: Creates a BSONDocumentWriter that writes tuple elements as BSONDocument fields.
-
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)]
EXPERIMENTAL: Creates a BSONDocumentWriter that writes tuple elements as BSONDocument fields.
-
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)]
EXPERIMENTAL: Creates a BSONDocumentWriter that writes tuple elements as BSONDocument fields.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()