2016-11-09 44 views
-2

这是我的JSON数据:给我一个MongoDB的查询

"tangoRewardList": [ 

{ 
    "_id": ObjectId("58107ee67a6e3f0504a2a14c"), 
    "brands": [{ 
     "description": "Tango Card", 
     "image_url": "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/tango-card-gift-card.png", 
     "rewards": [{ 
      "description": "Tango Card E-Custom", 
      "sku": "TNGO-E-V-STD", 
      "currency_code": "USD", 
      "available": true, 
      "type": "reward", 
      "countries": [ 
       "US" 
      ], 
      "is_variable": true, 
      "min_price": "1", 
      "max_price": "500000" 
     }] 
    }] 
} 

] 

请给我MongoDB的查询来获取min_pricemax_price

回答

0

尝试这个

db.collection.aggregate([{"$unwind" : "$tangoRewardList"},{"$unwind" : "$brands"},{$match : {tangoRewardList.brands.min_price : 1}}]) 
0
db.coll.find({},{"tangoRewardList.brand.minPrice":1,"tangoRewardList.brand.maxPrice":1}) 
+0

而使用此查询我没有得到这一个已经minPrice为1 –