Arangodb/Aql Update Array of Documents

Given the following document structure:

{
  "active": "N",
  "code": "AL",
  "id": 3,
  "mcc": "+355",
  "name": "Arango",
  "participant": [
    {
      "actor": {
        "reference": "Patient/example",
        "display": "Peter James Chalmers"
      },
      "required": "required",
      "status": "not booked"
    }
  ]
}

I want to update array of participant[*].status as "not booked" to "booked".

could you tell me the Arango query for update array value.

1 Answer

Here is a solution using an inline projection:

FOR doc IN coll
  FILTER doc._key == "<key>"
  UPDATE doc WITH {
    participant: doc.participant[* RETURN MERGE(CURRENT, {status: "booked"})]
  } IN coll

Note that this sets the status to "booked" for all objects in the participant array.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest