db.cata.aggregate([{"$unwind":"$review"},{$group:{_id:"review",cnt:{$sum:1}}}]).pretty()
db.cata.aggregate([{"$unwind":"$review"},{$group:{_id:"$review",cnt:{$sum:1}}}]).pretty()
what these two queries do in document..how $review and review do...how $ works with fields...
my document is
{
"_id" : ObjectId("56dd01bdf3b660327b932da1"),
"product" : "super",
"price" : 10,
"review" : [
{
"user" : "fred",
"comment" : "great",
"rating" : 10
},
{
"user" : "tom",
"comment" : "i agree",
"rating" : 3
},
{
"user" : "vin",
"comment" : "good",
"rating" : 9
},
{
"user" : "anubhav",
"comment" : "too good",
"rating" : 8
}]
}