I am using aggregate method in mongoDB to group but when I use $group it returns the only field which I used to group. I have tried $project but it
$group
$project
You can use this query
db.col.aggregate([ {"$group" : {"_id" : "$name","data" : {"$first" : "$$ROOT"}}}, {"$project" : { "tags" : "$data.tags", "name" : "$data.name", "rating" : "$data.rating", "_id" : "$data._id" } }])