Home:ALL Converter>Query distinct not null values in MongoDb

Query distinct not null values in MongoDb

Ask Time:2013-04-22T19:22:43         Author:hfogel

Json Formatter

I'm just beginning to learn MongoDb and am having some problems with distinct queries.

If I for instance run the query

db.images.distinct('gallery') 

I get the expected result, but also empty strings and null values. How can I write a query that just returns the values that are not null?

Thanks

Author:hfogel,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/16145962/query-distinct-not-null-values-in-mongodb
yy