Removing an array in an array in mongodb

In my mongo collection, I have a nested variable named "instit.type". This is an array with the following elements:

db.collection.distinct("institution.type") 
[
null,
[
    "boarding"
],
"virtual"
]

I am trying to delete entries using the "boarding" element, however I am stuck due to being inside the array by itself (an error originally made when using $ push for the array)

I tried to find the docs:

db.collection.find({"institution.type":{ $in: ["boarding"]}}).count()
0

and

db.collection.update({"institution.id":"somenumber"}, {$pull:   {"institution.type.1":"boarding"}})
"type" : [
        "virtual",
        [ ]
         ]

How to remove brackets along with the landing tag without receiving an error

JavaScript runtime error: SyntaxError: Unexpected identifier?

Any advice would be greatly appreciated and welcomed!

+4
source share
1 answer

, , ...

db.collection.find({"institution.type": {$in: [["boarding"]]}})

, :

db.collection.update({"institution.type": {$in: [["boarding"]]}}, {$pull: {"institution.type": ["boarding"]}})
+1

All Articles