ActiveRecord-like ORM library for Scala
Scala HTML Other
Latest commit 46e1b47 Jul 15, 2016 @y-yoshinoya y-yoshinoya committed on GitHub Update README.md
Failed to load latest commit information.
activerecord/src migration from Play Plugin to Play Module. bump Play version (2.5.x) Jul 4, 2016
bin
generator/src bump scalastyle version Jun 24, 2016
macro/src/main
notes
play2 Update README.md Jul 15, 2016
play2Sbt/src fixed library versions Jul 1, 2016
play2Specs/src/main/scala
project
scalatra
scalatraSbt/src
specs/src
.gitignore
CREDITS.txt
MIT-LICENSE.txt add credit and license file Apr 11, 2012
README.md Update README.md Jul 15, 2016
scalastyle-config.xml

README.md

Scala ActiveRecord maven central javadoc

scala-activerecord is an ORM library for Scala.

This library is inspired by ActiveRecord of Ruby on Rails. It is designed following the CoC(Convention over Configuration), DRY(Don't Repeat Yourself) principles.

Minimal example

Model implementation:

package models

import com.github.aselab.activerecord._
import com.github.aselab.activerecord.dsl._

case class Person(name: String, age: Int) extends ActiveRecord

object Person extends ActiveRecordCompanion[Person]

Schema definition:

package models

import com.github.aselab.activerecord._
import com.github.aselab.activerecord.dsl._

object Tables extends ActiveRecordTables {
  val people = table[Person]
}

ActiveRecord model usage:

import com.github.aselab.activerecord.dsl._
import models._

object App extends App {
  Tables.initialize

  Person("person1", 25).save
  Person("person2", 18).save
  Person("person3", 40).save
  Person("person4", 18).save

  Person.findBy("name", "person1") //=> Some(Person("person1", 25))
  Person.findBy("age", 55) //=> None
  Person.findAllBy("age", 18).toList //=> List(Person("person2", 18), Person("person4", 18))
  Person.where(_.age.~ >= 20).orderBy(_.age desc).toList //=> List(Person("person3", 40), Person("person1", 25))

  Tables.cleanup
}

Schema and query DSL is based on Squeryl.

Features

  • Auto connection management
  • Composable query operation
  • Callback
  • Validation
  • Association

Documents and other resources

Web framework support

License

MIT