Reputation: 10740
I have records in the collection:
{'name': 'mike', 'numbers': {'first': 1, 'fifth': 74}}
{'name': 'pete', 'numbers': {'third': 15, 'sixth': 12}}
And I need to find a max value of 'numbers', i.e. for this example it will be a single number 74 and 0 if there is no records.
Thanks for your answers.
Upvotes: 0
Views: 798
Reputation: 18625
Currently this is only possible through map/reduce although a new aggregation framework is under development (for progress keep an eye on https://jira.mongodb.org/browse/SERVER-447).
An m/r that does what you want can be found at http://cookbook.mongodb.org/patterns/finding_max_and_min/
Good luck.
Upvotes: 1