What will i do:
Suppose your Token class looks like this and you use mysql:
import org.joda.time.DateTime import com.github.tototoshi.slick.JdbcJodaSupport._ import play.api.db.slick.Config.driver.simple._ case class Token( id: Option[Long] expirationTime: Option[DateTime] ) class Tokens(tag: Tag) extends Table[Token](tag, "Token") { def id = column[Long]("id", O.PrimaryKey, O.AutoInc, O.Nullable) def expirationTime = column[DateTime]("expirationTime", O.Nullable) def * = (id.?, expirationTime.?) <> (Token.tupled, Token.unapply) }
Eg. Dependencies:
libraryDependencies ++= Seq( "com.typesafe.slick" %% "slick" % "2.1.0-M2", "com.typesafe.play" %% "play-slick" % "0.8.0-M1", "com.github.tototoshi" %% "slick-joda-mapper" % "1.2.0", "mysql" % "mysql-connector-java" % "5.1.26" )
Then you just need to:
import com.github.tototoshi.slick.JdbcJodaSupport._ DB.withSession { implicit session => Tokens.where(_.expirationTime < DateTime.now ).delete }
If you use any other db than mysql, you need to change the import and dependencies.
jakob source share