I have a collection which contains items in the following structure:
{
"_id" : ObjectId("55efa44a23588e5686f045e7"),
"gender" : "Male",
"preferredName" : "Alan Turning",
"hireDate" : "2013-06-04",
"totalExperience" : 4.27,
"employeeId" : "00001"
}
and also I have another collection like this:
{
"_id" : ObjectId("55efd19123588e5686f054b7"),
"skills" : [ ],
"employeeId" : "00001"
}
and I want to merge those two collection as :
{
"_id" : ObjectId("55efa44a23588e5686f045e7"),
"gender" : "Male",
"preferredName" : "Alan Turning",
"hireDate" : "2013-06-04",
"totalExperience" : 4.27,
"employeeId" : "00001",
"skills": []
}
in file map-reduce.js
, I defined two map function and one reduce function to do this, the result is putting into staff_skills
collection.