使用$ gt运算符在所有对象

时间:2017-05-12 07:23:04

标签: mongodb mongodb-query aggregation-framework

这是购物清单集合中的许多类似对象之一。如何进行查询以获取仅购买超过2个“面条”的人的“名称”列表? 请提前帮助我解决这个问题。

我认为这应该有$ gt运算符,但我不确定如何正确执行它。

{
    "_id" : ObjectId("591422529f75f9119575c1d8"),
    "name" : "Hisham",
    "age" : 20,
    "address" : {
        "house" : "HomeName",
        "street" : "Fairyland",
        "city" : "Faketon",
        "pincode" : 000000
    },
    "itemlist" : [
        {
            "iname" : "Soap",
            "quantity" : 2,
            "price" : 10,
            "rate" : 20,
            "itemID" : "1"
        },
        {
            "iname" : "Mirror",
            "quantity" : 1,
            "price" : 600,
            "rate" : 600,
            "itemID" : "4"
        },
        {
            "iname" : "Noodles",
            "quantity" : 4,
            "price" : 50,
            "rate" : 200,
            "itemID" : "5"
        },
        {
            "iname" : "Plug",
            "quantity" : 2,
            "price" : 50,
            "rate" : 100,
            "itemID" : "6"
        }
    ]
}

0 个答案:

没有答案