I have a Document in MongoDB with a list of Embedded Documents. let's take a simplified example of a car document with a list of tires:
{
"make": "Toyota",
"color": "blue",
"tires": [{
"make": "Mishlen",
"size": 185
}, {
"make": "Mishlen",
"size": 210
}]
}
When I ran the following query to find all cars with tire size below 200 I get the same document back but I don't know which of the tires matched the query.
{"tires.size": {$gt: 200}}
I'm trying to achive some kind of this result back:
{
"make": "Toyota",
"color": "blue",
"tires": [{
"make": "Mishlen",
"size": 185,
"matched": true
}, {
"make": "Mishlen",
"size": 210,
"matched": false
}]
}
This way I can tell which of the tires matched my query. What is the best way to achive this kind of result? in terms of performance.