Skip to content

Instantly share code, notes, and snippets.

@JJWTimmer
Created August 25, 2012 18:57
Show Gist options
  • Save JJWTimmer/3469291 to your computer and use it in GitHub Desktop.
Save JJWTimmer/3469291 to your computer and use it in GitHub Desktop.
table class
case class MyObject (
id: Long,
created: JodaTime
modified: JodaTime
special: JodaTime
)
object MyObjects extends Table[MyObject]("my_objects") {
lazy val database = Database.forDataSource(DB.getDataSource())
def id = column[Long]("id", O PrimaryKey, O AutoInc, O NotNull)
def created = column[JodaTime]("created", O NotNull)
def modified = column[JodaTime]("modified", O NotNull)
def special = column[JodaTime]("special", O NotNull)
def * = id ~ created <> (MyObject, MyObject.unapply _)
def getMarker(time: JodaTime) = database.withSession { implicit db:Session =>
(for {
e <- MyObjects if (new org.joda.time.Interval(e.created, e.modified).contains(e.special)
} yield (e.id, e.created)).firstOption
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment