Arangodb/Aql Update Array of Documents
Given the Following Document Structure: { "Active": "N", "Code": "Al", "Id": 3, "Mcc": "+355", "Name": "Arango", "Participant": [ { "Actor": { "Reference"...
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.