While exploring mongoose for nodejs I ran into the problem of needing to know the amount of user in my collection:
My collection has records, each record has a user
You can do a distinct query.
var Record = db.model('Record', yourSchema); Record.find().distinct('user').exec(callback);
Mongoose Queries: http://mongoosejs.com/docs/queries.html
MongoDB distinct query: http://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Distinct