MongoDB: operator to match arrays whose elements are all contained in a specified array
Depending on your version of MongoDB server there are a few ways to approach this. 

In MongoDB 3.6+ you can use the  $setIsSubset expression (which is true only when the first array given is a subset of the second) via the $expr operator:

&gt; db.haystack.find({$expr:{$setIsSubset:["$vals",["A","B","D"]]}},{_id:0})
{
    "name": 1,
    "vals": [
        "A",
        "B"
    ]
}
{
    "name": 3,
    "vals": [
        "A",
        "D"
    ]
}


For earlier versions of MongoDB a similar outcome is possible (but less obvious) using double negation with the $elemMatch operator:

&gt; db.haystack.find({$nor:[{vals:{$elemMatch:{$nin:["A","B","D"]}}}]},{_id:0})
{
    "name": 1,
    "vals": [
        "A",
        "B"
    ]
}
{
    "name": 3,
    "vals": [
        "A",
        "D"
    ]
}


Roughly translated: "find all documents where it is not the case that the vals array includes a value other than one in the provided list".