Created
August 25, 2012 18:57
-
-
Save JJWTimmer/3469291 to your computer and use it in GitHub Desktop.
table class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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