I am new to MongoDB and trying to do an integer search in embeded documents. The collection I have is following
db.inventory.insertMany([{
"store": "abc store",
"games": [{
"gameId": 12254,
"score": 88
},
{
"gameId": 12258,
"score": 70
},
{
"gameId": 12262,
"score": 98
}
]
}, {
"store": "xyz store",
"games": [{
"gameId": 18244,
"score": 88
},
{
"gameId": 18248,
"score": 25
},
{
"gameId": 18252,
"score": 66
}
]
}]);
What I want to search in the collection is for example 122 in games.gameId and get the following result
[{
"store": "abc store",
"games": [{
"gameId": 12254,
"score": 88
},
{
"gameId": 12258,
"score": 70
},
{
"gameId": 12262,
"score": 98
}
]
}]