Defining data
as
LET a = {
"user": "Thor Odinson",
"city": "New York",
"action": "Lives"
}
LET b = {
"user": "Thor Odinson",
"city": "New York",
"action": "Childhood"
}
LET data = [a,b]
To get the desired result for data
, this should get you started:
FOR i IN data
COLLECT user = i.user, city = i.city INTO groups = i.action
RETURN {"user": user, "city": city, "action": groups}
That gives the desired result:
[
{
"user": "Thor Odinson",
"city": "New York",
"action": [
"Lives",
"Childhood"
]
}
]
If you need more control over the variables returned, use KEEP
:
FOR i IN data
LET action = i.action
COLLECT user = i.user, city = i.city INTO groups KEEP action
RETURN {"user": user, "city": city, "action": groups[*].action}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…