I have a database containing some large objects, with always the same keys/structure:
{
"stats": {
"a": 100
"b": 0
"c": 30
"d": 20
...
"z": 100
}
},
{
"stats": {
"a": 200
"b": 2
"c": 10
"d": 40
...
"z": 100
}
}
I would like to know if there is a way to aggregate all stats sub-object without specifying all their fields using PyMongo. The desired output would be this:
"stats": {
"a": 150
"b": 1
"c": 20
"d": 30
...
"z": 100
}
I found this: Mongodb Is it possible to aggregate an object? but I am kinda unsure of how to use it in PyMongo.
EDIT: I could list all fields and aggregate them, but I am looking for a solution not listing those fields (I have approximately 100 of them).