2

postgresql データベースを slick とインターフェースしたいのですが、私の問題は、次のようなテーブルをどのように表現するかです。

    Column    |            Type             | Modifiers | Storage  | Description
--------------+-----------------------------+-----------+----------+-------------
 id           | bigint                      | not null  | plain    |
 version      | integer                     | not null  | plain    |
 tstamp       | timestamp without time zone | not null  | plain    |
 tags         | hstore                      |           | extended |
 nodes        | bigint[]                    |           | extended |

誰かが交換する方法についてのヒントを持っている場合は? の

object Ways extends Table[(?, Int, Int, java.sql.Timestamp, ?, ?, ?)]("WAYS") {
  def id = column[?]("id", O.PrimaryKey)
  def version = column[Int]("version")
  def user_id = column[Int]("user_id")
  def tstamp = column[java.sql.Timestamp]("tstamp")
  def changeset_id = column[?]("changeset_id")
  def tags = column[?]("tags")
  def nodes = column[?]("nodes")
  }

解決策になりArray[String]ますか?

4

1 に答える 1

3

slick-pgは、まさにこの問題に対処する拡張機能です。

import com.github.tminglei.slickpg._
trait ImplicitsPlus extends Implicits
                        with ArrayImplicits
                        with RangeImplicits
                        with HStoreImplicits
                        with SearchImplicits
                        with PostGISImplicits
  override val Implicit = new ImplicitsPlus {}
  override val simple = new SimpleQLPlus {}

  //////
  trait ImplicitsPlus extends Implicits
                        with ArrayImplicits
                        with RangeImplicits
                        with HStoreImplicits
                        with SearchImplicits
                        with PostGISImplicits

  trait SimpleQLPlus extends SimpleQL
                        with ImplicitsPlus
                        with SearchAssistants
}

object MyPostgresDriver extends MyPostgresDriver

object TestTable extends Table[Test](Some("xxx"), "Test") {
  def id = column[Long]("id", O.AutoInc, O.PrimaryKey)
  def during = column[Range[Timestamp]]("during")
  def location = column[Point]("location")
  def text = column[String]("text", O.DBType("varchar(4000)"))
  def props = column[Map[String,String]]("props_hstore")
  def tags = column[List[String]]("tags_arr")
}
于 2013-07-10T12:13:48.667 に答える