Database

db={restaurants:[{grades:[{"grade":"A","score":8},{"grade":"A","score":7}]},{grades:[{"grade":"B","score":8},{"grade":"B","score":6}]},{grades:[{"grade":"C","score":14},{"grade":"C","score":6}]}]}

Query

db.restaurants.aggregate([{$set:{min_modulo:{$reduce:{input:"$grades.score",initialValue:{"$maxKey":1},in:{$cond:{if:{$eq:["$$value",0]},/** in theory, once we have a 0* don't calculate mods or the minimums any more*/then:"$$value",else:{$min:[{$mod:["$$this",7]},"$$value"]}}}}}}},{$match:{min_modulo:0}}])

Result