为"?|"写pg-slick的过滤器操作者

时间:2017-02-28 10:48:31

标签: postgresql scala slick

我在编写查询时遇到了问题。

基本上我是在查询jsonb结构,这就是我的sql查询的样子:

select (p_product -> 'category_id') from product where p_product-> 'category_id' ?| array['3544', '3179'] limit 10;

以下是我尝试使用的scala代码:

  allEvents.filter(row => row.product +> "category_id" ?|.inSetBind(ids.map{_.id}))

这不起作用。

另一方面,我已经能够将文本比较用于:

row.product +>> "category_id" inSetBind(ids.map{_.id})

我试图在网上找到一些东西但我完全出于自己的想法。

1 个答案:

答案 0 :(得分:0)

我看了一下 https://github.com/tminglei/slick-pg/blob/master/addons/spray-json/src/test/scala/com/github/tminglei/slickpg/PgSprayJsonSupportSuite.scala

所以我把它合并到了:

allEvents.filter(row => row.product.+>("category_id") ?| ids.map{_.id}.toList.bind)