The approach I would suggest is aggregation. First of all, you have to perform $unwind on the list array and then implement $match. It will filter each and every element of the array and then after filtering, put it back together with the help of $group. For implementing the above-suggested tasks, refer to the following code:
db.test.aggregate([
{ $match: {_id: ObjectId("512e28984815cbfcb21646a7")}},
{ $unwind: '$list'},
{ $match: {'list.a': {$gt: 3}}},
{ $group: {_id: '$_id', list: {$push: '$list.a'}}}
])
The output is aas follows:
{
"result": [
{
"_id": ObjectId("512e28984815cbfcb21646a7"),
"list": [
4,
5
]
}
],
"ok": 1
}
If you are a beginner and want to know more about MongoDB, then check out the mongodb tutorial.