I would try to move the exact match of mission into each clause.

The query would then look like:

{
    $or: [
        {
            mission: ObjectId('67403f86d51c6db1e1ecd97b'),
            ref: ObjectId('64742caafe06f2171069def2'),
        },
        {
            mission: ObjectId('67403f86d51c6db1e1ecd97b'),
            permission: 1,
        },
    ],
}
2 Likes