Codecs

uk.gov.hmrc.mongo.play.json.Codecs
See theCodecs companion object
trait Codecs

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Codecs
Self type

Members list

Type members

Classlikes

implicit class BsonOps(bs: BsonValue)

Attributes

Supertypes
class Object
trait Matchable
class Any
implicit class DocumentOps(document: Document)

Attributes

Supertypes
class Object
trait Matchable
class Any
implicit class DocumentsOps(documents: Seq[Document])

Attributes

Supertypes
class Object
trait Matchable
class Any
implicit class JsonOps[A](a: A)(implicit evidence$1: Writes[A])

Attributes

Supertypes
class Object
trait Matchable
class Any
class SumCodecsBuilder[A]

Attributes

Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

def fromBson[A : Reads](bs: BsonValue): A
def playFormatCodec[A](format: Format[A])(implicit ct: ClassTag[A]): Codec[A]
def playFormatCodecsBuilder[A](format: Format[A])(implicit ct: ClassTag[A]): SumCodecsBuilder[A]

This variant of playFormatCodec allows to register a codec for subclasses, which are defined by a play format for a supertype. This is helpful when writing an instance of the subclass to mongo, since codecs are looked up by reflection, and the format will need to be registered explicitly for the subclass.

This variant of playFormatCodec allows to register a codec for subclasses, which are defined by a play format for a supertype. This is helpful when writing an instance of the subclass to mongo, since codecs are looked up by reflection, and the format will need to be registered explicitly for the subclass.

It makes it easier to register for multiple subclasses together.

E.g.

sealed trait Sum
case class Sum1() extends Sum
case class Sum2() extends Sum
val sumFormat: Format[Sum] = ...
 new PlayMongoRepository[Sum](
   domainFormat = sumFormat,
   extraCodecs  = Codecs.playFormatCodecsBuilder(sumFormat).forType[Sum1].forType[Sum2].build
 )

Attributes

def toBson[A : Writes](a: A): BsonValue

Inherited methods

inline def allInstances[ET <: Tuple, T]: List[ClassTag[T]]

Attributes

Inherited from:
CodecHelper (hidden)
inline def playFormatSumCodecs[A : SumOf](format: Format[A]): Seq[Codec[_]]

This variant of playFormatCodec allows to register codecs for all direct subclasses, which are defined by a play format for a supertype. This is helpful when writing an instance of the subclass to mongo, since codecs are looked up by reflection, and the format will need to be registered explicitly for the subclass.

This variant of playFormatCodec allows to register codecs for all direct subclasses, which are defined by a play format for a supertype. This is helpful when writing an instance of the subclass to mongo, since codecs are looked up by reflection, and the format will need to be registered explicitly for the subclass.

E.g.

sealed trait Sum
case class Sum1() extends Sum
case class Sum2() extends Sum
val sumFormat: Format[Sum] = ...
 new PlayMongoRepository[Sum](
   domainFormat = sumFormat,
   extraCodecs  = Codecs.playFormatSumCodecs(sumFormat)
 )

Attributes

Inherited from:
CodecHelper (hidden)

Concrete fields

val logger: Logger

Implicits

Implicits

final implicit def BsonOps(bs: BsonValue): BsonOps
final implicit def DocumentOps(document: Document): DocumentOps
final implicit def DocumentsOps(documents: Seq[Document]): DocumentsOps
final implicit def JsonOps[A : Writes](a: A): JsonOps[A]