longevity

A Persistence Framework for Scala and NoSQL

View project on GitHub

username and email

The final components of our user aggregate are Username and Email, which are the key values for the two User keys. Here’s the code for Username:

package simbl.domain

import longevity.model.annotations.keyVal

@keyVal[User]
case class Username(username: String)

Aside from being parts of our user aggregate, we can also embed them in other classes. For instance, BlogPost contains a Set[Username] to indicate the authors of the post:

case class BlogPost(
  uri: BlogPostUri,
  title: String,
  slug: Option[Markdown] = None,
  content: Markdown,
  labels: Set[String] = Set(),
  postDate: DateTime,
  blog: BlogUri,
  authors: Set[Username])
prev: the user profile
up: getting started guide
next: building the domain model