I am using mongoDB in which I have collection of following format.
{\"id\" : 1 , name : x ttm : 23 , val : 5 }
{\"id\" : 1 , name : x ttm : 34
If you want to write the distinct result in a file using javascript...this is how you do
cursor = db.myColl.find({'fieldName':'fieldValue'})
var Arr = new Array();
var count = 0;
cursor.forEach(
function(x) {
var temp = x.id;
var index = Arr.indexOf(temp);
if(index==-1)
{
printjson(x.id);
Arr[count] = temp;
count++;
}
})