Q:

Scala mongo driver custom codec for case classes

The scala-mongo-driver has a decent documentation for working with case classes. http://mongodb.github.io/mongo-scala-driver/2.3/getting-started/quick-tour-case-classes/. 
In current situation my case class fields are Option[T] values. So the values can be either None or Some(T).The default codec is now serializing 'None' values as null. But I want to exclude the key if its value is None. How can I obtain this behavior? From my research I think we need to write a custom Codec or Codec Provider for the case class instead of the default case class codec. 

A:

There is an new macro helper since v2.1.0: Macros.createCodecProviderIgnoreNone where you can define that None values will be ignored from saving to the DB. 

description of the bson-macros
scaladoc

