I have a document which looks like this:
{
"_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
}]
}
now I want to query using $where
for all items whose "qty">5
and "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'})
}
but it dosen't work. I want to do it only by using "$where"