I'm converting code from Casbah to mongodb-scala-driver, and when it comes to capturing the result of a query, the best I've come up with so far is:
var doc: Option[Document] = None
collection.find(and(equal("name",name),equal("hobby", hobby))).first().subscribe(
(result: Document) => doc = Some(result)
)
if (doc.isDefined) {
// ...
}
I just don't like the look of that. How can I improve it?