2 ms·
I'm currently using mongodb for a new project at work and the biggest surprise for me is that there is no elegant solution for doing the SQL equivalent of COUNT
by kingnothing 16y ago
I'm currently using mongodb for a new project at work and the biggest surprise for me is that there is no elegant solution for doing the SQL equivalent of COUNT(DISTINCT field). Count exists, distinct exists to return the set to you, but the combination isn't there.
The only solutions i have found are to check the length of the distinct query, which takes too long for a large result set, or to write a map reduce function which takes longer than I'd like and is a large amount of code for functionality that should already exist in the db.