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
Specify Query with distinct. The following example returns the distinct values for the field sku, embedded in the item field, from the documents whose dept is equal to "A":
db.inventory.distinct( "item.sku", { dept: "A" } )
Reference: https://docs.mongodb.com/manual/reference/method/db.collection.distinct/