I managed to get the identifier or any other field or even the whole object, returning the tuple from the save method.
def saveRoute(route: Route)(implicit writer: BSONDocumentWriter[Route]) = { collection.insert(route).map((_, route)) }
I copy the Route object and assign an ID generator before calling saveRoute
route.copy(id = Some(BSONObjectID.generate().stringify))
This approach allows me to get both WriteResult and saved entity
source share