Passing global variables to map and reduce functions can be very key requirements in some cases. However there is not enough information on how to access them in map and reduce functions, even on MongoDB documentation website.
This is my simple MapReduce command showing the usage of global variables.
Personally I would have liked to access the variables using scope.myNewKey i.e. making the scope available as single variable. We need to do some trial and error on how it behaves if we have nested document and many other combinations. Will share my findings as I dig deeper into the usage.