i'm writing a play 2.3 application in Scala. I use a mongoDB database and the ReactiveMongo driver. The method that i call to read/write/update the dates in the db return a Future[Option[T]]. My question is this: if i had a method that first update a document and after read the updated document i need an onComplete statement or not? For example:
def updatePasswordInfo(user: LoginUser,info: PasswordInfo): scala.concurrent.Future[Option[BasicProfile]] = {
import LoginUser.passwordInfoFormat //import the formatter
//the document query
val query = Json.obj("providerId" -> user.providerId,
"userId" -> user.userId
)
val newPassword = Json.obj("passswordInfo" -> info)// the new password
//search if the user exists and
val future = UserServiceLogin.update(query, newPassword) //update the document
for {
user <- UserServiceLogin.find(query).one
} yield user //return the new LoginUser
}
Is correct o i need to use onComplete statement before use the UserServicelogin.find(query).one
statement?