Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def findOne(id: BSONObjectID): Future[Option[reactive.models.User]] = {
- val query = BSONDocument("_id" -> id)
- val cursor = users.find(query).cursor[BSONDocument]
- for {
- // get a future option of user
- maybeUser <- cursor.headOption
- // if there is some user, return a future of result with the user
- result <- maybeUser.map { doc =>
- Option(userReader.read(doc))
- }.get
- } yield result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement