I have this arbitrary structure of a collection. Need to find a match on itemId. Here's the structure:
{
"_id" : "uHof564CDJcnvFHKz",
"user_id" : "dukcCKjFcQe2v7bHD",
"cart" : {
"createdAt" : ISODate("2016-04-19T18:12:52.456Z"),
"items" : [
{
"itemId" : "FfK49XAcX7YR",
"itemPrice" : "10",
"shortName" : "Item Description",
"itemType" : "item1"
},
{
"itemId" : "RgX6FfuK49XAcX",
"itemPrice" : "20",
"shortName" : "Item Description",
"itemType" : "item2"
}
]
}
So, I have an itemId and need to find a match in "cart -- items".
I tried $elemMatch, and multiple $elemMatch that did not work, returned null.