I have one collection in which student_id is the primary key:
test1:{student_id:"xxxxx"},
I have another collection in which student_id is inside array of collection:
class:{"class":"I",students:["student_id":"xxxx"]}
My problem is I want to join these two tables on the basis of student Id,
I am using map reduce and out as "merge", but it won't work.
My MR query is as follows.
db.runCommand({ mapreduce: "test1",
map : function Map() {
emit(this._id,this);
},
reduce : function Reduce(key, values) {
return values;
},
out : { merge: "testmerge" }
});
db.runCommand({ mapreduce: "class",
map : function Map() {
emit(this._id,this);
},
reduce : function Reduce(key, values) {
return values;
},
out : { merge: "testmerge" }
});
But it inserts two rows.
Can some one guide me regarding this,I am very new to MR
As in the example I want to get the details of all student from "test1" collection,studying in class "I".