Can anyone assist me in resolving this issue?
I am trying to achieve the following format:
true: 2,3,4
false: 5
I am using sequelize,
I am struggling with outputting JSON correctly
Please see my code snippet below. However, it is not functioning as expected.
const test = {
one: {
'user': '2',
'status': '1', block: {
'ok': 'false'
}
},
two: {
'user': '3',
'status': '1', block: {
'ok': 'false'
}
},
three: {
'user': '4',
'status': '1', block: {
'ok': 'false'
}
},
five: {
'user': '5',
'status': '0', block: {
'ok': 'true'
=======
}
}
const grouped = test.reduce((groups, test) => ({
...groups,
[test.user]: [...(groups[test.user] || []), test.block.ok]
}), {});
const text = Object.entries(grouped).map(([key, values]) => `${key}: ${values}`).join('\n');
console.log(text)