Is it possible some how to convince Mongodb driver to use default values for case class fields if no such field found?
Currently getting error:
case class TestMe(fieldname:String="defaultVal")
org.bson.BsonInvalidOperationException: Missing field: "fieldname"
P.S. I know that having it as a Option will not throw the error, bit next I will need to write extra code getOrElse("...")
which I would like to avoid.
Make sure that the data you are trying to decode has the field. If you are not persisting the entire case class in your request to the db, it could be that you are (not) updating the field of the case class individually, and so a read on the data is failing because it is not optional.
I lost some time, and probably some sweat and hair due to the same error message