Merge two records


#1

I have two documents as below

{
“type”: “client”,
“clients”: [
{
“name”: “loft”,
“versions”: [
“1.0”,
“1.1”,
“1.2”,
“1.3”
]
},
{
“name”: “express”,
“versions”: [
“1.0”
]
}
]
}

{
“type”: “versions”,
“versions”: {
“1.0”:“1.0.1”,
“1.2”:“1.2.1”,
“1.1”: “1.1.1”,
“1.3”:""
}
}

Output should be as below
[{
“clientName”: “loft”,
“versions”: [{
“type”: “major”,
“versionName”: “1.0”
}, {
“type”: “minor”,
“versionName”: “1.0.1”
}, {
“type”: “major”,
“versionName”: “1.1”
}, {
“type”: “major”,
“versionName”: “1.2”
}, {
“type”: “minor”,
“versionName”: “1.2.1”
}, {
“type”: “major”,
“versionName”: “1.3”
}]
}, {
“clientName”: “express”,
“versions”: [{
“type”: “major”,
“versionName”: “1.0”
}, {
“type”: “minor”,
“versionName”: “1.0.1”
}]

}]