Looks really simple, it would be 4-5 lines with any language. I am really stuck!
What I already have:

```
/* 1 */
{
    "_id" : ObjectId("5ad078cc43c90bb8118b457b"),
    "totalTime" : 323,
    "qData" : [ 
        {
            "qId" : "123456",
            "weight" : 38
        }, 
        {
            "qId" : "654321",
            "age" : 21
        },       
        {
            "qId" : "123456",
            "age" : 14
        }, 
        {
            "qId" : "654321",
            "height" : 122
        }, 
        {
            "qId" : "654321",
            "weight" : 34
        }
    ]
}

/* 2 */
{
    "_id" : ObjectId("5ad084cc43c90bb8118b4583"),
    "totalTime" : 312,
     "qData" : [ 
        {
            "qId" : "123456",
            "weight" : 42
        }, 
        {
            "qId" : "654321",
            "age" : 21
        },       
        {
            "qId" : "123456",
            "age" : 15
        }, 
        {
            "qId" : "654321",
            "height" : 124
        }, 
        {
            "qId" : "654321",
            "weight" : 40
        }
    ]
}

/* 3 */
{
    "_id" : ObjectId("5ad0853143c90bf4088b457b"),
    "totalTime" : NumberLong(20),
     "qData" : [ 
        {
            "qId" : "123456",
            "weight" : 48
        }, 
        {
            "qId" : "654321",
            "age" : 22
        },       
        {
            "qId" : "123456",
            "age" : 19
        }, 
        {
            "qId" : "654321",
            "height" : 162
        }, 
        {
            "qId" : "654321",
            "weight" : 39
        }
    ]
}

```

And where I need to go. This is just gathering data from within `qData` array for each `document`, based on `qId` of each element. Documents (records) do not mix their data (qData) at all.

```
/* 1 */
{
    "_id" : ObjectId("5ad078cc43c90bb8118b457b"),
    "totalTime" : 323,
    "qData" : [ 
        {
            "qId" : "123456",
            "weight" : 38,
            "age" : 14
        }, 
        {
            "qId" : "654321",
            "age" : 21,
            "height" : 122,
            "weight" : 34
        }
    ]
}

/* 2 */
{
    "_id" : ObjectId("5ad084cc43c90bb8118b4583"),
    "totalTime" : 312,
     "qData" : [ 
        {
            "qId" : "123456",
            "weight" : 42,
            "age" : 15
        }, 
        {
            "qId" : "654321",
            "age" : 21,
            "height" : 124,
            "weight" : 40
        }
    ]
}

/* 3 */
{
    "_id" : ObjectId("5ad0853143c90bf4088b457b"),
    "totalTime" : NumberLong(20),
     "qData" : [ 
        {
            "qId" : "123456",
            "weight" : 48,
            "age" : 19
        }, 
        {
            "qId" : "654321",
            "age" : 22,
            "height" : 162,
            "weight" : 39
        }
    ]
}

```

I need to do this with aggregation framework. Already tried $filter, with $map or $addToSet, already spent 10 hours on it. Cannot find the right combination. 

update: I forgot to mention, I run on 3.4 so `$mergeObjects` is not an option without update.