Есть массив:
let data = [
{
unique: 'qwerty',
id: '3222',
name: 90222,
count : 10
},
{
unique: 'qwerty',
id: '3222',
name: 90223,
count : 10
},
{
unique: 'qwerty',
id: '3222',
name: 90224,
count : 10
},
{
unique: 'qwerty',
id: '3222',
name: 90225,
count : 10
},
{
unique: 'qwerty',
id: '3223',
name: 90229,
count : 10
},
{
unique: 'qwerty',
id: '3223',
name: 90300,
count : 10
},
{
unique: 'qazx',
id: '8710',
name: 81999,
count : 14
},
{
unique: 'qazx',
id: '8710',
name: 82000,
count : 14
},
{
unique: 'qazx',
id: '8300',
name: 81000,
count : 14
},
{
unique: 'qazx',
id: '8300',
name: 81500,
count : 14
},
];
Надо собрать из него такой объект:
let obj = {
"qwerty": {
"3222": [
90222,
90223,
90224,
90225
],
"3223": [
90229,
90300
],
"count": 10
},
"qazx": {
"8710": [
81999,
82000
],
"8300": [
81000,
81500
],
"count": 14
}
};