一、数组中元素的查询
在MongoDB中存在以下数据,
"bookmark_num": NumberInt(0),
"category": {
"0": "MOOC",
"1": "paper"
},
"comment_num": NumberInt(0)
我要查询category 为paper的记录,在rockmongo中,可以直接这么写:
{
category: "paper"
}
即可。
二、有以下数据结构,查询content中不存在footer的记录:
"content": {
"header": "h1",
"footer": "f1",
"pa": ["1", "2"]
}
利用以下语句便可查询。
{
"content.footer": {$exists: false}
}