How to deal with references


I have seen this article on sub-document operations but it doesn’t fully answer my questions.

I am wondering if I can do some conditional updates with references ?

Assuming I have this data model:

    type: "user",
   addresses: [
          type: "adresse::shipment"
          id: "1234"
   id: 1234,
    type: "adresse::shipment",
   country: DE

Now, I want to update all users where country in the shipment address is DE. Can I do this in one transaction or do I have to get all ids of users via N1QL query, loop through each user and update it case by case?


Hi @Johnson,

Using a N1QL query should give you what you want here. Try a n1ql query like the following:
update bucketName
set fieldName = fieldValue
where country = “DE”

This should work. I am not to sure of the exact data model you are using, but it looks like there are no sub-docs. Check out this link for more information: Let me know if this doesn’t work for you.