I have a pipeline so far that looks like this:
db.getCollection("Members").aggregate(
[
    { 
        "$match" : {
            "member.MemberInfo.BusinessUnitCode" : "20"
        }
    }, 
    { 
        "$group" : {
            "_id" : "$_id", 
            "items" : {
                "$addToSet" : {
                    "Type" : "$member.MemberIdentifications.MemberIdentification.IdentificationType", 
                    "Value" : "$member.MemberIdentifications.MemberIdentification.Identifier"
                }
            }
        }
    }}
And I have results that are:
{ 
"_id" : ObjectId("53ad60c1600f5b241c693cbd"), 
"items" : [
    {
        "Type" : [
            "Medicaid ID", 
            "Medicare ID", 
            "Amisys ID", 
            "Social Security Number", 
            "Market Prominence ID", 
            "MBI", 
            "MPI"
        ], 
        "Value" : [
            "221075***", 
            "450807099M", 
            "C0004125301", 
            "45*******", 
            "N00020269104", 
            "3K13EA8EY99", 
            "17296217"
        ]
    }
]}
What I want is this:
{
"_id" : ObjectId("53ad60c1600f5b241c693cbd"),
{"Medicaid ID": "221075501",
 "Medicare ID": "450807099M",
 "Amisys ID": "C0004125301",
 "Social Security Number": "45*******",
 "Market Prominence ID": "N00020269104",
 "MBI": "3K13EA8EY99",
 "MPI": "17296217"
 }
}
In table view this would look like (obviously with many more records):
_id                         Medicaid ID Medicare ID Amisys ID   Social Security Number  Market 
53ad60c1600f5b241c693cbd    221075***   450807099M  C0004125301 45*******               N00020269104
I'm not sure what next steps to take. I've looked at a similar question about pivoting data in mongo to make rows columns here, but Its a different case and it doesnt really apply to mine. What Im basically doing is pivoting from the two sets I created so one set become the kets and one set becomes the values of one new document
 
    