nicklasos
4/11/2015 - 8:09 AM

mongodb uniq values

mongodb uniq values

// Count uniq values
pipeline = [ 
    { $group: { _id: "$internalId"}  },
    { $group: { _id: 1, count: { $sum: 1 } } }
];

//
// Run the aggregation command
//
R = db.runCommand( 
    {
    "aggregate": "logs" , 
    "pipeline": pipeline
    }
);
printjson(R);