Slide 32
Slide 32 text
Object Mapping in Scala via Salat
case class Book(id: ObjectId, author: Seq[Author], isbn: String,
price: Price, publicationYear: Int, tags: Seq[String],
title: String, publisher: String, edition: Option[String])
case class Author(name: String)
case class Price(currency: String, discount: Double, msrp: Double)
val authors = Seq( Author("Timothy Perrett") )
val price = Price("USD", 39.99, 39.99)
val tags = Seq("functional programming", "scala",
"web development", "lift", "#legendofklang")
val liftInAction = Book(new ObjectId, authors, "9781935182801",
price, 2011, tags,
"Lift in Action",
"Manning Publications Co.", Some("First"))
Salat uses Scala’s case classes as the core of
their model (immutability is good!)
Thursday, September 13, 12