Skip to content

Instantly share code, notes, and snippets.

@JonathonAshworth
Last active April 27, 2018 04:58
Show Gist options
  • Save JonathonAshworth/b2892bf4392c7ae75962ed69512397f5 to your computer and use it in GitHub Desktop.
Save JonathonAshworth/b2892bf4392c7ae75962ed69512397f5 to your computer and use it in GitHub Desktop.
Expanded vs Flat data
const data = {
people: [
{
id: 0,
name: 'John',
bankAccount: { id: 0, balance: 2864 },
address: { id: 0, number: 83, street: 'Foo St' },
},
{
id: 1,
name: 'Steve',
bankAccount: { id: 1, balance: 97831 },
address: { id: 0, number: 83, street: 'Foo St' },
},
],
}
const data = {
people: [
{ id: 0, name: 'John', bankAccount: 0, address: 1 },
{ id: 1, name: 'Steve', bankAccount: 1, address: 0 },
],
bankAccounts: [
{ id: 0, balance: 2864 },
{ id: 1, balance: 97831 },
],
addresses: [
{ id: 0, number: 83, street: 'Foo St' },
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment