I have a MongoDB collection containing elements like this:
{
"name": "test",
"instances": [
{
"year": 2015
},
{
"year": 2016
},
]
}
How can I get the minimum and maximum value for year
within the document named test
? E.g. I want to aggregate all documents inside that array, but I can't find the syntax for that. Thanks in advance!