MongoDB queries with null value

前端 未结 2 843
不思量自难忘°
不思量自难忘° 2020-12-11 01:16

My collection (MongoDB v 2.0.2) has following records:

db.organization.find({})
{ \"_id\" : 1001, \"path\" : [ ], \"parent\" : null }
{ \"_id\" : 1002, \"pat         


        
2条回答
  •  北海茫月
    2020-12-11 01:17

    I had the same issue. After reading the following documents

    • querying and nulls
    • BSON specification

    I tried to query for the different BSON element types and found that my null was represented as a BSON element type 6 (undefined, deprecated) instead of the expected BSON element type 10 (null).

    db.collection.find({ field: { "$type" : 6} };
    

提交回复
热议问题