2

我的产品在 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 } ]

4

1 回答 1

3

范围 501 - 1000,例如:

   db.collection.find({price: {$gte: 501, $lte: 1000}}).sort({price:1})
于 2015-11-26T11:12:59.390 回答