2021年4月2日星期五

How to format complicated array with ._groupBy

My array looks like:

data: [0: {code: "3019476", _id: "60033f61-8a4e-4622-9731-decd07bc44e1", vendor: "DKNY", tags: [{type: 1, label: dsfs},{type: 2, label: thisOne},{type: 3, label: sdas}]}      1: {code: "3019475", _id: "60033f61-8a4e-4622-9731-decd07bc44e0", vendor: "DKNY", tags: [{type: 1, label: sdfsd},{type: 2, label: anotherOne},{type: 3, label: sdfsd}]}      2: {code: "3019474", _id: "60033f61-8a4e-4622-9731-decd07bc44e9", vendor: "DKNY", tags: [{type: 1, label: gregf},{type: 2, label: thisOne},{type: 3, label: gregf}]}]  

I expect this as output (can be found here data[i].tags[1].label, only tag with type 2):

0: {title: "thisOne", data: Array(2)"}  1: {title: "anotherOne", data: Array(1)"}  

All my ideas failed, so I really need your help

https://stackoverflow.com/questions/66927767/how-to-format-complicated-array-with-groupby April 03, 2021 at 12:37PM

没有评论:

发表评论