i have many documents in "name" there, have find union of documents having same name value, eg:
{"name":"apple iphone 6","memory":"32gb"}, {"name":"apple iphone 6","memory":"16gb"} required result is
{"name":"apple iphone 6","memory":"16gb/32gb"}
you can result aggregation
db.coll.aggregate([ { "$group" : { "_id" : "$name", "memory": { "$addtoset": "$memory" } }} ]); output
{ "_id": "apple iphone 6", "memory": ["16gb", "32gb"]} then use array join method on result.memory
Comments
Post a Comment