I have documents that have metadata.
{
"_id": "6158d1e84cec41f47c8fde51",
"metadata": [
{
"source": [{info: "xxxxxx", timestamp: 0}, {info: "xxxyyy", timestamp: 1}],
"email": "xxx@xxx.xxx"
},
{
"source": [{info: "yyyyyy", timestamp: 0}, {info: "yyyxxx", timestamp: 1}],
"email": "yyy@yyy.yyy"
}
]
}
Starting with the sixth version of mongoose, an empty array was returned. The reason for this was that the condition below stopped working.
"metadata.source": {
"$exists": true,
"$not": {
"$size": 0
}
}
I wrote an alternative version that reduces the projection and it seems to work like that.
"metadata": {
"$elemMatch": {
"info": {
"$exists": true,
"$not": {
"$size": 0
}
}
}
}
But I wanted to know what was wrong with the first option, since everything works in mongodb compass and mongoose below the sixth version.