How to deal with references

Hi,

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?

Thanks,
Jan

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: https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/update.html. Let me know if this doesn’t work for you.

Thanks,
Korry