Postgresql 如何将普通PostgresSQL查询转换为平滑查询?
映射表Postgresql 如何将普通PostgresSQL查询转换为平滑查询?,postgresql,scala,slick,hstore,Postgresql,Scala,Slick,Hstore,映射表 Table: person 从地址->城市='芝加哥'的人员中选择* 请帮助我将上述简单查询转换为流畅查询。 我正在使用下面的技术堆栈及其版本 斯卡拉:2.11.11 滑头:3.2.0 光滑pg:0.15.4 看看slick pg中的HStore功能:或者你可以看看你有没有尝试过? case class Person(id: Int, name: String, address: Option[Map[String, String]]) trait ReceiptReposito
Table: person
从地址->城市='芝加哥'的人员中选择*
请帮助我将上述简单查询转换为流畅查询。
我正在使用下面的技术堆栈及其版本
- 斯卡拉:2.11.11
- 滑头:3.2.0
- 光滑pg:0.15.4
case class Person(id: Int, name: String, address: Option[Map[String, String]])
trait ReceiptRepositoryImpl {
self: PersonTable with SlickDBComponent =>
def getPersonByCity(city: String): List[Person] = {
personQuery.filter(_.address) // *Here i am unable to convert slick query of select * from person where address -> 'city' = 'Chicago'*
}
}
trait PersonTable {
this: SlickDBComponent =>
import driver.api._
val personQuery: TableQuery[PersonDetailsTable] = TableQuery[PersonDetailsTable]
class PersonDetailsTable(tag: Tag) extends Table[Person](tag, "person") {
def id: Rep[Long] = column[Long]("id", O.PrimaryKey, O.AutoInc)
def name: Rep[String] = column[String]("name")
def address: Rep[Option[Map[String, String]]] = column[Option[Map[String, String]]]("address")
def * = (id, name, address) <> (Person.tupled, Person.unapply)
}
}
id | name | address
----+---------+--------------------
1 | James | "city"=>"Chicago"
1 | Michael | "city"=>"New York"