mongodb $exists查询求解
>db.c1.find(){"_id":ObjectId("54fc56e830851f0bf0b3bc90"),"age":"23"}{"_id":ObjectId("...
>db.c1.find()
{ "_id" : ObjectId("54fc56e830851f0bf0b3bc90"), "age" : "23" }
{ "_id" : ObjectId("54fc571030851f0bf0b3bc91"), "user" : null, "age" : "23" }
> db.c2.find({user:{$exists:1}})
{ "_id" : ObjectId("54fc56e830851f0bf0b3bc90"), "age" : "23" }
为什么为空的user 还能查询出来 展开
{ "_id" : ObjectId("54fc56e830851f0bf0b3bc90"), "age" : "23" }
{ "_id" : ObjectId("54fc571030851f0bf0b3bc91"), "user" : null, "age" : "23" }
> db.c2.find({user:{$exists:1}})
{ "_id" : ObjectId("54fc56e830851f0bf0b3bc90"), "age" : "23" }
为什么为空的user 还能查询出来 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询