My supposition was wrong. Even in Mongo 2.4 $size: 0 only matches if you have an array:
> db.t.insert({"a": []})
> db.t.find()
{ "_id" : ObjectId("5bdea1bb8952436077782726"), "a" : [ ] }
> db.t.find({"a": {$size: 0}})
{ "_id" : ObjectId("5bdea1bb8952436077782726"), "a" : [ ] }
> db.t.find({"b": {$size: 0}})
> exit
We'll need to check how you can get into this situation. I don't know what would be deleting the arrays vs just removing items from it, and if we do need that behavior, then we should handle it in the cleanup with an $or clause.
My supposition was wrong. Even in Mongo 2.4 $size: 0 only matches if you have an array: "5bdea1bb895243 6077782726" ), "a" : [ ] } "5bdea1bb895243 6077782726" ), "a" : [ ] }
> db.t.insert({"a": []})
> db.t.find()
{ "_id" : ObjectId(
> db.t.find({"a": {$size: 0}})
{ "_id" : ObjectId(
> db.t.find({"b": {$size: 0}})
> exit
We'll need to check how you can get into this situation. I don't know what would be deleting the arrays vs just removing items from it, and if we do need that behavior, then we should handle it in the cleanup with an $or clause.