MongoDB count aggregate per month -


is there way total number of documents in mongodb database months (for example, can display chart showing evolution of number of users) in single request? or should request each month individually?

i don't want see number of users created in month total (this month + previous months).

each document in collection has field representing date created. total number of documents in mongodb database months, use range query query documents value created_on greater date representing start of month, , less date representing end.

assume start date 'start' , end date 'end'. query be,

db.users.count({created_on: {$gte: start, $lt: end}});

here nice explanation relevant topic. http://cookbook.mongodb.org/patterns/date_range/

refer answers in thread also. find objects between 2 dates mongodb


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -