I am new to mongodb aggregate queries. So can’t wrap my head around this problem.
How should i find a document where ‘quanity.storage’ = “SHOP” have 0 qty. but some other storage have at least 1 qty available?
{
"desc": { "name": "Item 1"},
"quantity": [
{ "storage": "SHOP", "qty": 0 },
{ "storage": "GODOWN", "qty": 1 },
{ "storage": "GODOWN 2", "qty": 0 }
]
},
{
"desc": { "name": "Item 2"},
"quantity": [
{ "storage": "SHOP", "qty": 1 },
{ "storage": "GODOWN", "qty": 0 },
{ "storage": "GODOWN 2", "qty": 1 }
]
}
I want query to return –
{
"desc": { "name": "Item 1"},
"quantity": [
{ "storage": "SHOP", "qty": 0 },
{ "storage": "GODOWN", "qty": 1 },
{ "storage": "GODOWN 2", "qty": 0 }
]
}