MongoDb: Array not recognized as array

I have this type of data:

    "_id" : "JpD9KSDmJCgjHc8Rc", 
    "data" : [
   "_id" : "JpD9KSDmJCgjHc8Rc", 
   "data" : "gajHSDjhdS" //binary.toString()


So I want the array data:
Coll.find({data: {$type: 4}}) //4 =Array

It does not return the arrays.
So I try:
Collfind({data: {$type: 2 //String/}}).map(function(i){
return typeof});

And my result is something like:
[“string”, “string”, “object”, “string”, “object”]

Querying for $type: 3 (object) gives nothing. I don’t get it…

From the Mongo docs:

When applied to arrays, $type matches any inner element that is of the specified type. Without projection this means that the entire array will match if any element has the right type. With projection, the results will include just those elements of the requested type.

You can use something like the following instead:

Coll.find({ $where : "Array.isArray(" });

Also note the following warning from Mongo:

Data models that associate a field name with different data types within a collection are strongly discouraged.
Without internal consistency complicates application code, and can lead to unnecessary complexity for application developers.

I ended up looping through it all and check them individually, but I think your suggestion would have worked, thanks.

Regarding the warning at the end - that is exactly why I needed to do this, the data part is “incoming” and provider changed format without consultation so I needed a split/cleanupp.