I have retraining and buying collections that are related to information about transection and purchases, now I want to transform it into a single collection. based on transectionid we need to combine documents
Below are the details of my conversion collection.
{ "transectionid": "1", "transectionamount": "2000", "transectiondate": "2016-07-12 19:22:28", }, { "transectionid": "2", "transectionamount": "1000", "transectiondate": "2016-07-12 20:17:11", }
below is my build details
{ "purchaseid": "1", "transectionid": "1", "itemprice": "1200", "itemcode": "edcvb", "itemquantity": "1", }, { "purchaseid": "2", "transectionid": "1", "itemprice": "800", "itemcode": "dfgh", "itemquantity": "2", }, { "purchaseid": "3", "transectionid": "2", "itemprice": "1000", "itemcode": "zxcvb", "itemquantity": "1", }
my expectation result: this is how the order collection {
"transectionid" : "1", "transectionamount": "2000", "transectiondate": "2016-07-12 19:22:28", "items" : [ { "purchaseid": "1", "itemprice":"1200", "itemcode": "edcvb", "itemquantity": "1", }, { "purchaseid": "2", "itemprice": "800", "itemcode": "dfgh", "itemquantity": "2", } ] } { "transectionid" : "2", "transectionamount": "1000", "transectiondate": "2016-07-12 20:17:11", "items" : [ { "purchaseid": "3", "itemprice":"1000", "itemcode": "zxcvb", "itemquantity": "1", } ] }