MongoDB aggregation framework match OR

aggregation-frameworkmongodb

Is it possible to do an OR in the $match?

I mean something like this:

db.articles.aggregate(
    { $or: [ $match : { author : "dave" }, $match : { author : "john" }] }
);

Best Answer

$match: { $or: [{ author: 'dave' }, { author: 'john' }] }

Like so, since the $match operator just takes what you would normally put into the find() function