How to create an aggregate query in JS where $in contains null?

182 Views Asked by At

This MongoDB query executes fine in the shell:

db.MyCollection.aggregate([
    {
        $match: {
            "language": { "$in": [null, "en"]}
        }
    }
]).pretty()

The query returns documents where the language field is missing or has value null or en.

I try to create the same query with the Parse SDK in Javascript:

const query = new Parse.Query("MyCollection");
const pipeline = {
    "match":{"language":{"$in":[null,"en"]}},
};

const results = await query.aggregate(pipeline);

The query returns only documents where the language field has value en, but not where the field is missing.

How can I get the same results in JS?

0

There are 0 best solutions below