I have a document structured as follows:
{
"_id" : ObjectId("564d2702d4c68225cb00726f"),
"list" : [
{
"a" : NumberInt(1),
"test" : "public"
},
{
"a" : NumberInt(2),
"test" : "public"
},
{
"a" : NumberInt(3),
"test" : "public"
},
{
"a" : NumberInt(4),
"test" : "public"
},
{
"a" : NumberInt(5),
"test" : "public"
}
],
"other_fields": ""}
Can I filter the subdocument for a in (1, 5)
My expected result below
{
"_id" : ObjectId("564d2702d4c68225cb00726f"),
"list" : [
{
"a" : NumberInt(1),
"test" : "public"
},
{
"a" : NumberInt(5),
"test" : "public"
}
]}
I try to use $elemMatch, but when I use $in, an error has occurred.
source
share