为什么会这样呢?对于这种差异是否有合乎逻辑的解释?
例如,我有一个db结构:
{
id: "1"
category: {
name: "name1"
groups: [
{
groupName : "groupName1"
title: ""
},
{
groupName : "groupName2"
title: ""
}
]
}
}
查询如下;
db.collection.aggregate({$unwind:"$category.groups"},
{$match:{"category.groups.groupName": "groupName2",
"category.name" : "name1"}})
在mongo shell中,它返回为;
{
id: "1"
category: {
name: "name1"
groups: [
groupName : "groupName2"
title: ""
]
}
}
在node.js中查询;
db.collection.aggregate({$unwind:"$category.groups"},
{$match:{"category.groups.groupName": "groupName2",
"category.name" : "name1"}}).
toArray(function(err, result) {
if (result) {
debugger;
var res = result;
}
});
};
在node.js中的结果是什么;
{
id: "1"
category: {
name: "name1"
groups: [
{
groupName : "groupName1"
title: ""
},
{
groupName : "groupName2"
title: ""
}
]
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句