我有一个看起来像这样的文件:
{
"_id" : ObjectId("50a8240b927d5d8b5891743c"),
"cust_id" : "abc",
"ord_date" : ISODate("2012-10-03T18:30:00Z"),
"status" : "A",
"price" : 25,
"items" : [
{
"sku" : "mmm",
"qty" : 5,
"price" : 2.5
},
{
"sku" : "nnn",
"qty" : 5,
"price" : 2.5
}]
}
现在我想查询$where
所有的"qty">5
和的项目"sku"=='mmm'
,
I tried the following
{
"$where" : "this.items.some(function(entry){return entry.qty>5})&&this.items.some(function(entry){return entry.sku=='ggg'})
}
但它不起作用。我只想通过使用“$where”来做到这一点