How can i update a Document which is stored in array like this below. I for example want to create a new key of bounce = true for id = 5e683b61-b168-498f-ba71-3ae4b6d4d668
i can get the doc via below but how does translate into an update / SET
select e from Contacts c
UNNEST c.emails e
where c._type= "customer" and e.address = "demo2@hotmail.com"
UPDATE Contacts AS c
SET e1.bounce = true FOR e1 IN c.emails WHEN e1.id = "5e683b61-b168-498f-ba71-3ae4b6d4d668" END
WHERE c._type= "customer" AND ANY e IN c.emails SATISFIES e.id = "5e683b61-b168-498f-ba71-3ae4b6d4d668" END;
Thanks, how can one delete a doc from array via N1QL if i have the unique ID like 5e683b61-b168-498f-ba71-3ae4b6d4d668 and i want to remove the complete DOC which has that ID
You need to use Array construct and build new array
UPDATE Contacts AS c
SET c.emails = ARRAY e1 FOR e1 IN c.emails WHEN e1.id != "5e683b61-b168-498f-ba71-3ae4b6d4d668" END
WHERE c._type= "customer" AND ANY e IN c.emails SATISFIES e.id = "5e683b61-b168-498f-ba71-3ae4b6d4d668" END;
UPDATE Contacts AS c
SET e1.bounce = true FOR e1 IN c.emails WHEN e1.id = "5e683b61-b168-498f-ba71-3ae4b6d4d668" END
WHERE c._type= "customer" AND ANY e IN c.emails SATISFIES e.id = "5e683b61-b168-498f-ba71-3ae4b6d4d668" END;