LoginSignup
0
0

More than 5 years have passed since last update.

finatra 三歩目

Last updated at Posted at 2016-06-24

quill で select を投げて結果を取得する

GroupRepository.scala
  def list(): TwitterFuture[List[Groups]] = {
    val q = quote(query[Groups])
    (for {
      r <- db.run(q)
    } yield r)

selectで全件取得するのに必要なのはこれだけです。

さて、しかし困りました

Finatraが扱うのは com.twitter.util.Future であって scala.concurrent.Future ではありません。

ドキュメントにはtwitter/bijection使ったらええよって書いてあるんですが、com.twitter.bijection.twitter_util.UtilBijections.twitter2ScalaFuture のimportが上手く行かない・・・

なので
http://stackoverflow.com/questions/30317473/convert-scala-future-to-twitter-future
のコードを全部コピーします。

これでFutureの変換ができるようになって結果を取得できるようになります。

GroupController.scala
  get("/group") { request: Request =>

    val list = groupRepository.list()

    list
  }

コード全容

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0