使用 JSON 的 Postgrest OR 查询
Postgrest OR query with JSON
我有一个 json 使用 postgrest 进行的查询,我需要接受 2 个场景。
该值必须等于 "failover" 或为空(不存在)。
如果没有 JSON 参与,这将是一个简单的 or=(device_type.eq.failover,device_type.is.null)
但是...对于我来说,我无法使用 OR 和 JSON 一起进行查询...
event->labels->>device_type=eq.failover
第一种情况下效果很好。
event->labels->>device_type=is.null
适用于第二种情况。但是如何将它们组合成一个 OR 语句呢?
我试过:
or=(event->labels->>device_type=is.null,event->labels->>device_type=eq.failover)
event->labels->>device_type=or(eq.failover,is.null)
event->labels->>device_type.or=(eq.failover,is.null)
但所有这些只是 return 400 错误请求错误...
知道如何在 postgrest 中将 JSON 匹配与 OR 语句相结合吗?
请求应该是:
or=(event->labels->>device_type.is.null,event->labels->>device_type.eq.failover)
基本上,在 or
查询字符串参数中使用点 .
(而不是 =
)作为分隔符。
我有一个 json 使用 postgrest 进行的查询,我需要接受 2 个场景。
该值必须等于 "failover" 或为空(不存在)。
如果没有 JSON 参与,这将是一个简单的 or=(device_type.eq.failover,device_type.is.null)
但是...对于我来说,我无法使用 OR 和 JSON 一起进行查询...
event->labels->>device_type=eq.failover
第一种情况下效果很好。
event->labels->>device_type=is.null
适用于第二种情况。但是如何将它们组合成一个 OR 语句呢?
我试过:
or=(event->labels->>device_type=is.null,event->labels->>device_type=eq.failover)
event->labels->>device_type=or(eq.failover,is.null)
event->labels->>device_type.or=(eq.failover,is.null)
但所有这些只是 return 400 错误请求错误...
知道如何在 postgrest 中将 JSON 匹配与 OR 语句相结合吗?
请求应该是:
or=(event->labels->>device_type.is.null,event->labels->>device_type.eq.failover)
基本上,在 or
查询字符串参数中使用点 .
(而不是 =
)作为分隔符。