What is the correct way to do a HAVING in a MongoDB GROUP BY?
New answer using Mongo aggregation framework After this question was asked and answered, 10gen released Mongodb version 2.2 with an aggregation framework. The new best way to do this query is: db.col.aggregate( [ { $group: { _id: { userId: “$userId”, name: “$name” }, count: { $sum: 1 } } }, { $match: { count: { … Read more