I have read the documentation and searched all over but I can’t find how to do it.
If I have a document inside a collection and the document is an empty array I can remove it like this:
db.data.remove(array('document'=>array()))
or like this:
db.data.remove(array('document'=>[]))
But if the array is not empty it doesn’t work, so I tried like this:
db.data.remove(array('document'=>array('$type'=>4)))
Am I doing it wrong? Is there any way to do this?
Removing the document on another criteria isn’t useful for me.
Edit:
Finally I found out what your problem is.
The
$typeoperator looks inside the array, not the array itself so the following find returns nothing:Now in my testcase the document contains a double, the following find returns the document:
Please see also the bug report about this topic:
https://jira.mongodb.org/browse/SERVER-1475