查詢集合c中y的值為null或者不存在
>db.c.find( { “y” : null } )
查詢集合c中y的值為null,(僅返回y的值為null的數據,不會返回不存在的)
>db.c.find( { “y” : { $type : 10 } } )
還有一種寫法如下
>db.c.find({“y”:{“$in”:[null], “$exists”:true}})
查詢集合c中y的值不存在(不會返回y的值為null的數據)
>db.c.find( { “y” : { $exists : false } } )
查詢集合c中y的值不為null且存在的記錄
>db.c.find( { “y” : {"$ne":null, $exists: true }} )
或者:>db.c.find( { “y” : {"$ne":null }} )