I have a data set on mongo like:
{"month": 9, "year": 2015, "name": "Mr A"}
{"month": 9, "year": 2015, "name": "Mr B"}
{"month": 10, "year": 2015, "name": "Mr B"}
{"month": 11, "year": 2016, "name": "Mr B"}
I am trying to get the minimum date from this using monger, but without any luck.
The best i could do was coming up with distinct month and year using:
(mc/aggregate mongo-connection collection-name [{$group { :_id { :month "$month", :year "$year" } } }]))
Which gave result like:
[{"_id":{"year":2016,"month":11}},
{"_id":{"year":2016,"month":10}},
{"_id":{"year":2016,"month":9}}]
And then I am using clojure libraries to get minimum date. Is there any direct way using monger?