MongoDB Aggregate Count: countDocuments(), $count and Group By Counts
Counting documents sounds like a one-liner until a report wants totals per state, per status and per date range at once. MongoDB gives you countDocuments(), estimatedDocumentCount(), the aggregate $count stage and $group, and each fits a different job. In this tutorial, I’ll cover each MongoDB aggregate count pattern on one small orders collection, with real … Read more >>