获取基于产品的价格范围使用MongoDb ..?

时间:2015-11-26 10:47:10

标签: node.js mongodb logic price

我的产品是在Mongo系列中维护的。

请建议mongo查询,该查询将根据可用产品数量及其相应价格获取价格范围。我有以下产品系列..

[ { "_id": "563b2574db70394054f35dc5", "category": { "id": "101010" }, "brand": { "name": "Global Desi" }, "is_active": true, "parent_sku": "88903689927175", "price": 1234, "sku": "1321asas", "name": "Buddha print kurta", "quantity": 1 }, { "_id": "563b2574db70394054f35dc6", "category": { "id": "101010" }, "brand": { "name": "Global Desi" }, "is_active": true, "parent_sku": "88903689927175", "price": 5678, "sku": "1322asas", "name": "Buddha print kurta", "quantity": 1 }, { "_id": "563b2574db70394054f35dc7", "category": { "id": "101010" }, "brand": { "name": "Global Desi" }, "is_active": true, "parent_sku": "88903689927175", "price": 2345, "sku": "1323asas", "name": "Buddha print kurta", "quantity": 1 }, { "_id": "563b2574db70394054f35dc8", "category": { "id": "101010" }, "brand": { "name": "Global Desi" }, "is_active": true, "parent_sku": "88903689927175", "price": 7890, "sku": "1324asas", "name": "Buddha print kurta", "quantity": 1 } ]

1 个答案:

答案 0 :(得分:1)

范围501 - 1000,例如:

   db.collection.find({price: {$gte: 501, $lte: 1000}}).sort({price:1})