All projects

Person.scala
case class Person(name: String,
                  age: Int,
                  _id: Id[Person] = Person.id())
  extends Document[Person]

object Person extends DocumentModel[Person]
  with JsonConversion[Person] {
  override implicit val rw: RW[Person] = RW.gen

  val name: I[String] = field.index("name", _.name)
  val age: I[Int] = field.index("age", _.age)
}

db.people.transaction { tx =>
  tx.query
    .filter(_.age BETWEEN 20 -> 29)
    .sort(Sort.ByField(Person.name))
    .toList
}

LightDB

One typed database API over many storage engines.

Open source

An open-source Scala database layer: define your models once, then store them in an embedded engine or on a database server, and keep the same queries and transactions.

View on GitHub

Switching storage engines doesn't mean rewriting your queries.

Storage engines

  • Embedded: RocksDB, LMDB, HaloDB, ChronicleMap, MapDB, SQLite, H2, DuckDB, Lucene, and Tantivy.
  • Server: PostgreSQL with pgvector, MariaDB and MySQL, MongoDB, ArangoDB, OpenSearch, Qdrant, and Redis.

Stores can be combined: keep documents in one engine and search indexes in another, split a collection across stores, or shard it.

What you get on every store

  • Typed models and queries checked by the compiler
  • Transactions, indexes, and distinct values
  • Aggregation, grouping, and streaming results
  • Full-text, spatial, and vector search
  • Graph traversal
  • Backup and restore, chunked file storage, reindexing, and upgrades

Where it runs

LightDB holds the data for Sigil, NaboTV, Voidcraft, and the site you are reading. It is MIT licensed and published to Maven Central. The latest version is listed on GitHub:

libraryDependencies += "com.outr" %% "lightdb-all" % "<version>"