簡體   English   中英

為“?|”運算符編寫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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM