3.4.2.7 判断某个字段是否存在
使用“$exists”可以判断某个字段是否存在,如果设置为true表示存在,false表示不存在。
范例:查询具有parents成员的数据
db.students.find({"parents" : {"$exists" : true}}).pretty()
范例:查询不具有course成员的数据
db.students.find({"course" : {"$exists" : false}}).pretty()
可以利用此类查询来进行一些不需要的数据的过滤。