Query on array of array object in mongodb

27 views
Skip to first unread message

Ashesh Khatri

unread,
Jul 10, 2016, 6:44:12 AM7/10/16
to Mongoose Node.JS ODM

Following is my product collection in mongodb..

{
    "_id" : ObjectId("56d42389db70393cd9f47c22"),
    "sku" : "KNITCHURI-BLACK",
    "options" : [
        {
            "sku" : "KNITCHURI-BLACK-M",
            "stores" : [
                {
                    "code" : "6",
                    "quantity" : 0
                },
                {
                    "code" : "10",
                    "quantity" : 26
                }
            ],
            "ean_code" : "2709502",
            "size" : "M"
        },
        {
            "sku" : "KNITCHURI-BLACK-S"
            "stores" : [
                {
                    "code" : "6",
                    "quantity" : 0
                },
                {
                    "code" : "10",
                    "quantity" : 30
                }
            ],
            "size" : "S"
        }
    ]
}

want query on where { 'options.stores.code' : '6' } and { 'options.stores.quantity' : { $gt : 0 } }, How i query on this collection then i got response? Kindly help on this issue..

Toshan Verma

unread,
Jul 11, 2016, 3:32:35 AM7/11/16
to mongoo...@googlegroups.com
Hi,

Please find below the Query
db.dummy.find({"options.stores.code" : "6", "options.stores.quantity" : { $gt : 0 }})


On 10-Jul-2016, at 4:14 PM, Ashesh Khatri <ash...@ambab.com> wrote:

'options.stores.quantity' : { $gt : 0 }

Reply all
Reply to author
Forward
0 new messages