SyntaxFix
Write A Post
Hire A Developer
Questions
You can use $addToSet with the aggregation framework to count distinct objects.
For example:
db.collectionName.aggregate([{ $group: {_id: null, uniqueValues: {$addToSet: "$fieldName"}} }])