为 "?|" 编写 pg-slick 过滤器操作员

Writing filter for pg-slick for "?|" operator

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

基本上我是在查询 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})

我正试图在网上找到一些东西,但我几乎没有自己的想法。

我看过了 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)