You’re close, but you need to use a $sum
operator to count the groupings:
db.users.aggregate([ {
$group: {
_id: "$status",
amt: { $sum: 1 }
}
} ] )
More Related Contents:
- Does MongoDB’s $in clause guarantee order
- Authentication failure while trying to save to mongodb
- Possibility of duplicate Mongo ObjectId’s being generated in two different collections?
- How to change the type of a field?
- MongoDB logging all queries
- Converting string to date in mongodb
- Querying internal array size in MongoDB
- MongoDB wildcard in the key of a query
- How to create a DB for MongoDB container on start up?
- How to access a preexisting collection with Mongoose?
- How to delete N numbers of documents in mongodb
- How do I query for distinct values in Mongoose?
- MongoDB field order and document position change after update
- MongoDB Full and Partial Text Search
- Difference between count() and find().count() in MongoDB
- How to insert an element to MongoDB internal list?
- Hierarchical queries with Mongo using $graphLookup
- Remove embedded document in a nested array of documents
- Find all documents within last n days
- Unable to create/open lock file: /data/mongod.lock errno:13 Permission denied
- Search on multiple collections in MongoDB
- Image returned from REST API always displays broken
- MongoDB: Server has startup warnings ”Access control is not enabled for the database”
- Mongo group and push: pushing all fields
- How to stop insertion of Duplicate documents in a mongodb collection
- Filtering embedded documents in MongoDB
- Remove multiple documents from mongo in a single query
- MongoDB on Ubuntu won’t start as a service, nothing in the log
- Mongodb concat int and string
- Query for a field in an object in array with Mongo?