mongo db count unique code example Example: mongodb count distinct db.collection.distinct('field').length