I have class MyClass with Option field (e.g. f:Option[String]). I update it by the value (e.g. Some("abc")) and it warks. If I change it on another value (e.g. Some("xyz")) it works too. But I cannot update it on None now. There is no error. Simply value is not changed and I face old one. My update method
def update(id: String, document: T)(implicit writer: Writes[T]): Future[Either[ServiceException, T]] = {
document.update = Some(new DateTime())
Logger.debug(s"Updating document: [collection=$collectionName, id=$id, document=$document]")
Recover(collection.update(DBQueryBuilder.id(id), DBQueryBuilder.set(document))) {
document
}
}
in DBQueryBuilder:
def id(objectId: String): JsObject = id(BSONObjectID(objectId))
def id(objectId: BSONObjectID): JsObject = Json.obj(jsId -> objectId)
def set[T](data: T)(implicit writer: Writes[T]): JsObject = Json.obj(SET -> data)
and
implicit val myClassDbFormat: Format[MyClass] = Json.format[MyClass]
I can see proper field values in logs but if value = None => nothing I use play2-reactivemongo 0.10.5.0.akka23. Scala.
Thanks in advance