db.getCollection('table').aggregate([
{
$group: { _id: {id: '$id', date: '$date', type: '$type'}, count: {$sum: 1},dups: {$addToSet: '$_id'}}
},
{
$match: {count: {$gt: 1}}
}
]).forEach(function(doc){
doc.dups.shift();
db.getCollection('table').remove({_id: {$in: doc.dups}});
})