Function in Mongo Shell. MongoshUnimplementedError: Unable to handle 'this' keyword outside of method definition

Viewed 644

enter image description here

var mapFunc = function() {
    for(i = 0; i < this.students.length; i++){
        var student = this.students[i];
 
        // Emit gets 2 arguments being the key on which you want to group the 
        // data and the data itself
        emit(student.fName + " " + student.lName, 1);
    }
};

MongoshUnimplementedError: Unable to handle 'this' keyword outside of method definition What should I do it?

0 Answers
Related