Database
[{"collection":"collection","count":10,"content":{"_id":{"type":"autoincrement","autoType":"int"},"name":{"type":"faker","method":"Name"},"scores":{"type":"array","minLength":3,"maxLength":3,"arrayContent":{"type":"object","objectContent":{"score":{"type":"double","min":35.0,"max":100.0},"type":{"type":"enum","values":["exam","quiz","homework"]}}}}}}]
Query
db.collection.aggregate([{"$set":{"allPass":{"$reduce":{"input":"$scores","initialValue":true,"in":{"$switch":{"branches":[{"case":{"$eq":["$$this.type","exam"]},"then":{"$and":["$$value",{"$gte":["$$this.score",40.0]}]}},{"case":{"$eq":["$$this.type","quiz"]},"then":{"$and":["$$value",{"$gte":["$$this.score",40.0]}]}},{"case":{"$eq":["$$this.type","homework"]},"then":{"$and":["$$value",{"$gte":["$$this.score",40.0]}]}}]}}}}}},{"$set":{"Status":{"$cond":["$allPass","Pass","Fail"]},"allPass":"$$REMOVE"}}])