A Persistence Framework for Scala and NoSQL

View project on GitHub

basic values

In the previous examples, we saw how to build a persistent object with a few String members. Of course, we can build persistent objects with other kinds of members than that. The simplest kinds are basic values, allowing you to put in members with a number of simple types:

  • java.lang.String
  • org.joda.time.DateTime
  • scala.Boolean
  • scala.Char
  • scala.Double
  • scala.Float
  • scala.Int
  • scala.Long

For example, we might add a few fields to our User like so:

import longevity.model.annotations.persistent
import org.joda.time.DateTime

case class User(
  username: String,
  firstName: String,
  lastName: String,
  dateJoined: DateTime,
  numCats: Int,
  accountSuspended: Boolean = false)
We recommend using nscala-time to wrap your Joda-Time dates in a Scala-friendly wrapper.
prev: persistent objects
up: the domain model
next: collections