在 jsonb 列中搜索 json 数组,其数据在 PostgreSQL 中为 json 数组

Search for a json array in jsonb column having data as json array in PostgreSQL

我的 table 文档中有一个 jsonb 列 (gppermission),其中包含的数据为

[{"Deny": "true", "Allow": "false", "GroupName": "Group 1 "}, 
 {"Deny": "false", "Allow": "true", "GroupName": "Group 2 "}, 
 {"Deny": "false", "Allow": "true", "GroupName": "Group 3 "}, 
 {"Deny": "true", "Allow": "false", "GroupName": "Group 4 "}]

我需要在此数据中搜索

{"Deny": "false", "Allow": "true", "GroupName": "Group 3 "}

我尝试了以下查询。但没有结果:(

select * from doc as dc ,jsonb_array_elements(dc.gppermission) as e(gp) where e.gp = '{"Deny":"false","Allow":"true","GroupName":"Group 3"}'

看到 Query for array elements inside JSON type 但它有一个 'object' 引用,我的 json 数组不同

请帮忙...

我有一个解决方案,这可能不是唯一的解决方案。

select * from doc as dc ,jsonb_array_elements(dc.gppermission) as e(gp) where e.gp ->>'Deny'='false' and e.gp ->>'Allow'='true' and e.gp ->>'GroupName'='Group 1'