Last active
August 29, 2015 14:07
-
-
Save ferromir/ed49ecb156f0cc051a5e to your computer and use it in GitHub Desktop.
MongoDB doc with embedded array to case classes objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Pet(name: String, kind: String) | |
case class Owner(name: String, pets: List[Pet]) | |
implicit def toOwner(doc: foos.T) = Owner( | |
name = doc.as[String]("name"), | |
pets = doc.as[MongoDBList]("pets").map(_.asInstanceOf[BasicDBObject]).map { p => | |
Pet(p.as[String]("name"), p.as[String]("kind")) | |
} toList | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment