FOR document in complexCollection
LET alteredList = (
FOR element IN document.subList
LET newItem = (! element.filterByMe ?
element :
MERGE(element, { attributeToAlter: "shiny New Value" }))
RETURN newItem)
UPDATE document WITH { subList: alteredList } IN complexCollection
参考:https://www.arangodb.com/docs/3.4/aql/examples-data-modification-queries.html
FOR u IN users
LET friends = (
FOR f IN friends
FILTER u.id == f.userId
RETURN f
)
LET memberships = (
FOR m IN memberships
FILTER u.id == m.userId
RETURN m
)
RETURN {
"user" : u,
"friends" : friends,
"numFriends" : LENGTH(friends),
"memberShips" : memberships
}
参考:https://www.arangodb.com/docs/3.3/aql/operations-let.html