longevity

A Persistence Framework for Scala and NoSQL

View project on GitHub

project setup

scala version

We currently publish artifacts for Scala versions 2.11 and 2.12, so be sure your project is using a compatible Scala version. For example, your build.sbt file may have:

scalaVersion := "2.11.12"

or:

scalaVersion := "2.12.6"

using sonatype artifacts

Include the following two lines in your build.sbt to declare the dependency:

resolvers += Resolver.sonatypeRepo("releases")

libraryDependencies += "org.longevityframework" %% "longevity" % "0.27.0"

Include one of the following lines to bring in the library dependencies for the back end of your choice:

libraryDependencies += "org.longevityframework" %% "longevity-cassandra-deps" % "0.27.0"

libraryDependencies += "org.longevityframework" %% "longevity-mongodb-deps" % "0.27.0"

libraryDependencies += "org.longevityframework" %% "longevity-sqlite-deps" % "0.27.0"

All longevity artifact versions move in lock-step, so it can be convenient to store it in a variable, like so:

val longevityVersion = "0.27.0"
libraryDependencies += "org.longevityframework" %% "longevity"                % longevityVersion
libraryDependencies += "org.longevityframework" %% "longevity-cassandra-deps" % longevityVersion
libraryDependencies += "org.longevityframework" %% "longevity-migrations"     % longevityVersion

enabling macro annotations

You will most likely want to use the macro annotations provided in package longevity.model.annotations. To do so, you will need to add Macro Paradise to your build, like so:

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

supplying optional dependencies

There are a number of optional longevity features that require you to bring in other library dependencies yourself. If you want to use cats.effect.IO as an effect, you will need cats-effect:

libraryDependencies += "org.typelevel" %% "cats-effect" % "0.10.1"

If you want to stream query results to Akka Streams:

libraryDependencies += "com.typesafe.akka" %% "akka-stream" % "2.5.12"

If you want to stream query results to FS2:

libraryDependencies += "co.fs2" %% "fs2-core" % "0.10.4"

If you want to stream query results to iteratee.io:

libraryDependencies += "io.iteratee" %% "iteratee-core" % "0.17.0"

If you want to stream query results to Play enumerators:

libraryDependencies += "com.typesafe.play" %% "play-iteratees" % "2.6.1"

If you want to use longevity.test.RepoCrudSpec or longevity.test.QuerySpec to build integration tests, you will need ScalaTest:

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5"
prev: what is longevity
up: preliminaries
next: the domain model