Database
[{"key":1},{"key":2}]
Query
/** whichever collection doesn't matter; as long as it has 1 document then it should be fine*/db.collection.aggregate([{/** jsut take 1 document*/"$limit":1},{/** use $range to generate iterator [1, 2, 3]*/"$addFields":{"rg":{"$range":[1,4]},globalVar:0.001}},{/** do the mapping according to logic*/"$addFields":{"cte":{"$map":{"input":"$rg","as":"n","in":{n:"$$n",f1:{"$multiply":["$$n",20]},f2:{"$cond":{"if":{$lt:[{"$multiply":["$$n",6]},{"$multiply":["$globalVar",100]}]},"then":{"$multiply":["$$n",6]},"else":{"$multiply":["$globalVar",100]}}}}}}}},{/** wrangle back to expected form*/"$unwind":"$cte"},{"$replaceRoot":{"newRoot":"$cte"}}])