angular / in-memory-web-api

The code for this project has moved to the angular/angular repo. This repo is now archived.
MIT License
1.18k stars 232 forks source link

hierarchical data collection #173

Open Massimiliano-Perelli opened 6 years ago

Massimiliano-Perelli commented 6 years ago

Sorry, it is possible to have something like this and than call api/heroes/11/children/13 to get Bombasto?

createDb() { const heroes = [ { id: 11, name: 'Mr. Nice', children: [ { id: 13, name: 'Bombasto' }, { id: 14, name: 'Celeritas' }, ] }, { id: 12, name: 'Narco' } ]; return {heroes}; }

arturhun commented 5 years ago

IMO that would make the library too much opinionated. children property is not the only way to reflect hierarchical data. Another user might have/need a flat data structure where the children would have a parentId property on them to reflect the relation.