Pinal
December 26, 2019, 8:14am
1
Hi,
[
{
“bucket”: {
“abc”: “5435345”,
“def”: “content”,
“__version”: “1.0”,
“map”: {
“1111”: {
“table”: {},
“order”: 1,
“group”: “DEPT”,
“id”: “1111”,
“name”: “Slot 1”,
},
“2222”: {
“table”: {},
“order”: 14,
“group”: “TEAM”,
“id”: “2222”,
“name”: “Slot 2”,
},
How to delet/select json element where “group”= “TEAM”
Thanks
Pinal
vsr1
December 26, 2019, 8:37am
2
SELECT *
FROM default
WHERE ANY v IN OBJECT_PAIRS(map) SATISFIES v.val.`group` = "TEAM" END;
DELETE FROM default
WHERE ANY v IN OBJECT_PAIRS(map) SATISFIES v.val.`group` = "TEAM" END;
https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/objectfun.html
Pinal
December 26, 2019, 9:03am
3
Its selecting all group value…
vsr1
December 26, 2019, 1:43pm
4
If you need specific group only
SELECT v.*
FROM default
UNNEST OBJECT_PAIRS(map) AS v
WHERE v.val.`group` = "TEAM" END;