longevity

A Persistence Framework for Scala and NoSQL

View project on GitHub

collections

Longevity supports the following “collection” types within your domain objects:

  • scala.Option
  • scala.collection.immutable.Set
  • scala.collection.immutable.List

For example, we can add an optional title property to our user, to hold values like “Mr.”, “Mrs.”, “Sir”, and “Brother”. And we can allow the user to have multiple emails:

import longevity.model.annotations.persistent

@persistent(keySet = emptyKeySet)
case class User(
  username: String,
  title: Option[String],
  firstName: String,
  lastName: String,
  emails: Set[String])

It’s on our TODO list to handle a wider variety of collection types, including Maps. But this basic set of collections should satisfy your needs. If you are itching to use another collection type in your domain model, please let us know! But please note that we will only ever support immutable collections. It is important that the persistent objects are immutable, so that longevity can keep track of any changes.

prev: basic values
up: the domain model
next: components