Let me explain this question by starting with a basic example.
Given a collection,
[
{
"name": "A",
"range": {
"min": 10,
"max": 100
}
},
{
"name": "B",
"range": {
"min": 3,
"max": 50
}
}
]
And given a number N. If I want to find the documents whose range contains the number N. I can use the following query,
db.collection.find({
"range.min": {
$lte: N
},
"range.max": {
$gte: N
}
})
It works well.
But if the range becomes multiple, I have no idea how to do the query.
An example for the colleciton,
[
{
"name": "A",
"ranges": [
{
"min": 10,
"max": 20
},
{
"min": 30,
"max": 50
},
{
"min": 80,
"max": 100
}
]
},
{
"name": "B",
"ranges": [
{
"min": 3,
"max": 10
},
{
"min": 20,
"max": 50
}
]
}
]