0

I need to group the data by sub categories, but the property is an array.

I'll appreciate your help, since I'm not good with sql.

Example

const data = [
  { 
     title: "data 1",
     sub_categories:[{ id: 1, name: 'gold'},{ id: 2, name: 'water' }]
  },
  { 
     title: "data 2",
     sub_categories:[{ id: 2, name: 'water'}]
  },
 { 
     title: "data 3",
     sub_categories:[{ id: 1, name: 'gold'},{ id: 3, name: 'fire' }]
  },
 { 
     title: "data 4",
     sub_categories:[] // also can be empty
  }
]
Chris Michael
  • 319
  • 6
  • 18

0 Answers0