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
I just needed the number of distinct musicians, but some of the code above did not work for me. If I used count and distinct together I just got the total number.
This was my solution:
/**
* Get number of distinct musicians
*/
myList.find()
.distinct('musicianName')
.exec(function (err, count) {
console.log(count.length);
});