Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 74 additions & 69 deletions docs/usage/structuring-reducers/NormalizingStateShape.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,69 +74,69 @@ An example of a normalized state structure for the blog example above might look

```js
{
posts : {
byId : {
"post1" : {
id : "post1",
author : "user1",
body : "......",
comments : ["comment1", "comment2"]
posts: {
byId: {
post1: {
id: "post1",
author: "user1",
body: "......",
comments: ["comment1", "comment2"]
},
"post2" : {
id : "post2",
author : "user2",
body : "......",
comments : ["comment3", "comment4", "comment5"]
post2: {
id: "post2",
author: "user2",
body: "......",
comments: ["comment3", "comment4", "comment5"]
}
},
allIds : ["post1", "post2"]
allIds: ["post1", "post2"]
},
comments : {
byId : {
"comment1" : {
id : "comment1",
author : "user2",
comment : ".....",
comments: {
byId: {
comment1: {
id: "comment1",
author: "user2",
comment: "....."
},
"comment2" : {
id : "comment2",
author : "user3",
comment : ".....",
comment2: {
id: "comment2",
author: "user3",
comment: "....."
},
"comment3" : {
id : "comment3",
author : "user3",
comment : ".....",
comment3: {
id: "comment3",
author: "user3",
comment: "....."
},
"comment4" : {
id : "comment4",
author : "user1",
comment : ".....",
},
"comment5" : {
id : "comment5",
author : "user3",
comment : ".....",
comment4: {
id: "comment4",
author: "user1",
comment: "....."
},
comment5: {
id: "comment5",
author: "user3",
comment: "....."
}
},
allIds : ["comment1", "comment2", "comment3", "comment4", "comment5"]
allIds: ["comment1", "comment2", "comment3", "comment4", "comment5"]
},
users : {
byId : {
"user1" : {
username : "user1",
name : "User 1",
users: {
byId: {
user1: {
username: "user1",
name: "User 1"
},
"user2" : {
username : "user2",
name : "User 2",
user2: {
username: "user2",
name: "User 2"
},
"user3" : {
username : "user3",
name : "User 3",
user3: {
username: "user3",
name: "User 3"
}
},
allIds : ["user1", "user2", "user3"]
allIds: ["user1", "user2", "user3"]
}
}
```
Expand All @@ -158,11 +158,11 @@ A typical application will likely have a mixture of relational data and non-rela
{
simpleDomainData1: {....},
simpleDomainData2: {....},
entities : {
entities: {
entityType1 : {....},
entityType2 : {....}
},
ui : {
ui: {
uiSection1 : {....},
uiSection2 : {....}
}
Expand All @@ -178,28 +178,33 @@ Because we're treating a portion of our Redux store as a "database", many of the
```js
{
entities: {
authors : { byId : {}, allIds : [] },
books : { byId : {}, allIds : [] },
authorBook : {
byId : {
1 : {
id : 1,
authorId : 5,
bookId : 22
authors: {
byId: {},
allIds: []
},
books: {
byId: {},
allIds: []
},
authorBook: {
byId: {
1: {
id: 1,
authorId: 5,
bookId: 22
},
2 : {
id : 2,
authorId : 5,
bookId : 15,
2: {
id: 2,
authorId: 5,
bookId: 15
},
3 : {
id : 3,
authorId : 42,
bookId : 12
3: {
id: 3,
authorId: 42,
bookId: 12
}
},
allIds : [1, 2, 3]

allIds: [1, 2, 3]
}
}
}
Expand Down