I am new to MongoDB. I am trying to get field values for a particular sku from the array in the document. I tried query ({"items.sku":"abc"},{"items.price":1}) but it is giving prices for both skus. I would appreciate if anybody can tell me how I can get price for only sku:"abc" i.e 3.5?
{ "_id": 123,
"store": "store1",
"items": [ { sku: "abc", qty: 4, price: 3.5 },
{ sku: "def", qty: 3, price: 2.5 } ]
}