Skip to content

Instantly share code, notes, and snippets.

@applethepeanut
Created December 2, 2016 15:25
Show Gist options
  • Save applethepeanut/ff70a7c7ded860db7e71547073c9aa63 to your computer and use it in GitHub Desktop.
Save applethepeanut/ff70a7c7ded860db7e71547073c9aa63 to your computer and use it in GitHub Desktop.
implicit object AccountReader extends BSONDocumentReader[Account] {
override def read(bson: BSONDocument): Account = {
val account: Option[Account] = for {
id <- bson.getAs[BSONObjectID]("_id")
...
} yield new Account(id, ...)
account.getOrElse(boom)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment