MongoDB 集約フレームワークの一致または質問する

MongoDB 集約フレームワークの一致または質問する

$match で OR を実行することは可能ですか?

つまり、次のようなことです:

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

ベストアンサー1

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

このように、演算子は通常関数$matchに入力するものを取得するだけなのでfind()

おすすめ記事