aggregation framework - MongoDB Aggregate Group with element name defined by data -
I am trying to collect the following in Mongo:
{"customer_id "," Value ": 101} {" customer_id ": 1," attribute ":" test2 "," value ": 102} {" customer_id ": 2," attribute ":" test1 "," value ": 101} {"Test1" :: 101, "test2" :: 102}} {"customer_id": "test1"> : 2, "attributes": {"test1" :: 201, "test2" :: 202}}
I've come very close by using the $ group and $ push, but It still creates an array instead of associative array {{"$ Group": {"_id": "$ customer_id", "Features ": {" $ Push ": {" attribute ":" The $ attribute "," value ":" $ Value "}}}}
There is no way of doing this?
Comments
Post a Comment