Understanding Scala Play Actions and Futures
<p>I've really been struggling with some of these concepts in Scala and Play. I want to update my database, and I think I need to wrap my database update function in a Future, but I don't know how to return the required <code>play.api.mvc.Result</code>. </p>

<p>I have a controller in Scala that returns some response:</p>

<pre><code>def somePath = MyCustomAction.async(parse.tolerantJson) { implicit request =&gt;
    request.body.validate[MyObject].map { myObject =&gt;
        for {
            getSomething &lt;- getSomethingFuture
            getSomethingElse &lt;- getSomethingElseFuture
        } yield {
            if (getSomethingElse) {
                if (getSomething)
                    updateMyDatabase(myObject)//perform database request
                else
                    BadRequest("Invalid request")
            }
        } else {
            // do some other things
        }
    }
}

private [this] def updateMyDatabase(myObject: MyObject) {
    // do things to update the database
}
</code></pre>

<p>Should updateMyDatabase be returning a <code>Result</code>? Do I want to wrap it in a Future and check if it completed successfully? And if I check, do I then return the correct <code>Result</code> on the <code>Success</code> method?</p>

<p>Right now, I'm not understanding how to structure these things or how to actually implement a <code>Future</code> based solution.</p>