mongodb - Mongo distinct query returns several records one of which is "". But find null fails to find it -


i ran distinct query on collection. query syntax:

db.collection.distinct("dict.field") 

i got set of results - 1 of "" (null).

i tried find record had null value field in question:

db.collection.find({"dict.field": null}) 

to surprise, no record found.

no indexes set on collection other _id.

the field in question dictionary.

what missing?

you should db.collection.find({"dict.field": ""}) instead. null , string ("") considered different datatypes.

https://docs.mongodb.com/manual/reference/bson-types/


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -