Previously I used findAndUpdate and could add fetchNewObject = true so I was able to do something like this after the query:
.map(_.result[WhicherReport].getOrElse {
throw new NoSuchElementException
})
but I'm using transaction now and could only perform update.one(...) and there is no option to pass it fetchNewObject, what can I do?
This is my func:
def someUpdateFunc(collection: BSONCollection, metadata: Metadata, ids: List[String]): Future[UpdateWriteResult] = {
collection.update.one(
q = Json.obj("metadata" -> metadata,
notLocked(now)),
u = Json.obj("$set" -> Json.obj("expenses.$[elem].paired" -> true)),
upsert = false,
multi = false,
arrayFilters = Seq(BSONDocument("elem.id" -> BSONDocument( "$in" -> ids))),
collation = None)
}
and I want to return the new updated case class using ReactiveMongo.