Skip to content

Instantly share code, notes, and snippets.

/post.scala
Created Aug 10, 2017

Embed
What would you like to do?
the description for this gist
val slickInterpreter = new Language[Future] {
/// I've skipped the Slick related part, you probably seen it 100 times already
private val slickPersonQuery = TableQuery[SlickPersonTable]
override type QueryObj = Query[SlickPersonTable, Person, Seq]
override def people(): Future[Raw] = {
Future.successful(Raw(slickPersonQuery))
}
override def filterByIds(query: Future[Raw], ids: Seq[Int]): Future[WithFilter] = {
query.map(_.q.filter(_.id inSet ids)).map(WithFilter)
}
override def paginate(query: Future[WithFilter], skip: Int, limit: Int): Future[WithPagination] = {
query.map(_.q.drop(skip).take(limit)).map(WithPagination)
}
override def run(query: Future[WithPagination]): Future[Seq[Person]] = {
query.flatMap { case finalQuery =>
db.run(finalQuery.q.result)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.