MongoDB code for Mapreduce,Aggregation and Index
[student@localhost ~]$ su Password: su: Authentication failure [student@localhost ~]$ su Password: [root@localhost student]# systemctl start mongod [root@localhost student]# ./mongo bash: ./mongo: No such file or directory [root@localhost student]# mongo MongoDB shell version: 2.4.6 connecting to: test > use spp switched to db spp > db.createCollection("fruits"); { "ok" : 1 } > db.fruits.insert({"name":"Apple","cost":200}) > db.fruits.insert({"name":"Apple","cost":200}) > db.fruits.insert({"name":"Apple","cost":300}) > db.fruits.mapReduce(function(){emit(this.name,this.price);}function(key,values){return Array.sum(values)},{out:"MapReduce_F"}).find(); Thu Jan 1 14:51:33.905 SyntaxError: Unexpected token function > db.fruits.mapReduce(function(){emit(this.name,this.cost);}function(key,values){return Array.sum(values)},{out:&qu