Check out the following query:
db.models.findOne({ "value.userId": { $ne: null } }, { "value.userId":1}).value.userId == null
This says:
- Find a record that has a non-null user id field
- Return the user id in the result
- Compare that value to null
Since we're returning only records without null values, comparing the result of that to null should always return false. However, this always returns true.
If I just do the .findOne(...) and print that instead of doing the comparison, I get:
{ "_id": 4, "value": { "userId": null }
Anyone have a clue what's going on here?
EDIT: the "type" of this field is apparently 6 - not 10, which is what a null should be. EDIT2: apparently type 6 is "undefined" - not sure why it prints null...