I tried mongodb,
db.getCollection('productList').find({"season": {$elemMatch: {'$gte':2018,'$lte':2020}}, team:"Arsenal"})
for above query i got the following result,
{
"_id": ObjectId("46ab3e933434234f"),
"team": "Arsenal",
"season": [2018, 2020]
},{
"_id": ObjectId("46ab3e933434234f"),
"team": "Arsenal",
"season": [2017, 2018] //I don`t want because of 2017
},{
"_id": ObjectId("46ab3e933434234f"),
"team": "Arsenal",
"season": [2020, 2021] //I don`t want because of 2021
},{
"_id": ObjectId("46ab3e933434234f"),
"team": "Arsenal",
"season": [2018, 2019]
},{
"_id": ObjectId("46ab3e933434234f"),
"team": "Arsenal",
"season": [2019, 2020]
},
I want to get the following result,
{
"_id": ObjectId("46ab3e933434234f"),
"team": "Arsenal",
"season": [2018, 2020]
},{
"_id": ObjectId("46ab3e933434234f"),
"team": "Arsenal",
"season": [2018, 2019]
},{
"_id": ObjectId("46ab3e933434234f"),
"team": "Arsenal",
"season": [2019, 2020]
},
I want to get the season between "2018 ~ 2020" only.