I am trying to return a field of every object in my collection in form of array using mapReduce function. These are my documents in a collection.
{ _id: '1', name: 'a' },
{ _id: '2', name: 'b' },
{ _id: '4', name: 'c' },
{ _id: '5', name: 'd' },
{ _id: '6', name: 'e' },
{ _id: '7', name: 'f' }
Now i want result in this form ['a','b','c','d','e','f']. How i can achieve it, i tried mapReduce but couldn't get the result in this way.
This is my code
collection.mapReduce( function EachBranch( ) {
emit( this.name, this.value);
}, function ( key, values ) {
},{ out: { inline: 1 } });