mongodb 文档数组查询的一个问题
滿天的星座
滿天的星座 2017-04-27 09:02:45
0
2
830

1对多群发消息,文档结构如下:

{
"from_uid" : 10000,
"to_uid" :
[

{ "user_id" : 100002, "is_read" : 1, "is_del" : 1 }, 
{ "user_id" : 100003, "is_read" : 0, "is_del" : 0 }, 
{ "user_id" : 100004, "is_read" : 1, "is_del" : 0 } 

]
}

其中to_uid.user_id=100002,设置为is_del=1。执行以下指令的时候,这个文档还会显示。 貌似查询条件里的"to_uid.user_id" "to_uid.is_del" 是或的关系?

db.notice.find({"to_uid.user_id":100002, "to_uid.is_del":0 , "create_time":8})

滿天的星座
滿天的星座

reply all(2)
仅有的幸福

db.notice.find({"to_uid":{$elemMatch:{"user_id":100002,"is_del":0}}"create_time":8})

Peter_Zhu

I encountered the same problem, and I always thought it was or , not &&,
I wonder if the author has solved it?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template