Hello!I have a field that stores an array of objects that looks like this:
players:
[
{
"assists": 0,
"deaths": 0,
"hero": "hero_name",
"team": 2,
"playerId": 0,
"steamId": "1234",
"kills": 0,
},
{
"assists": 0,
"deaths": 0,
"hero": "hero_name",
"team": 1,
"playerId": 0,
"steamId": "5678",
"kills": 0,
}
]
I’d like to create an aggregate query that returns the total kills based on a user’s steamId, and I’ve tried this query:
group={"objectId":{"steamId" : "$players.steamId"},"total":{"$sum":"$players.kills"}}
The response looks something like this:
{
"results": [
{
"total": 0,
"objectId": {
"steamId": [
"1234"
]
}
},
{
"total": 0,
"objectId": {
"steamId": [
"1234",
"5678"
]
}
},
{
"total": 0,
"objectId": {
"steamId": [
"1234",
"9876"
]
}
}
]
}
How should I modify the query such that my response returns something like this instead?
{
"results": [
{
"total": 0,
"objectId": {
"steamId": [
"1234"
]
}
},
{
"total": 0,
"objectId": {
"steamId": [
"5678"
]
}
},
{
"total": 0,
"objectId": {
"steamId": [
"9876"
]
}
}
]
}
Thanks very much for the help in advance!