Skip to content

Commit a531f36

Browse files
committed
docs update
1 parent a1279bb commit a531f36

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed

README.md

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -77,50 +77,6 @@ console.log(normalize(json));
7777
*/
7878
```
7979

80-
# Data Representation Feature
81-
One-to-Many relationship is merged into one map like this
82-
83-
```JavaScript
84-
const json = {
85-
data: [{
86-
type: "post-block",
87-
id: "1",
88-
attributes: { ... },
89-
relationships: {
90-
posts: {
91-
data: [{
92-
type: "post",
93-
id: "1"
94-
}, {
95-
type: "post",
96-
id: "2"
97-
}]
98-
}
99-
},
100-
...
101-
}]
102-
}
103-
104-
console.log(normalize(json));
105-
/* Output:
106-
{
107-
postBlock: {
108-
"1": {
109-
...,
110-
relationships: {
111-
posts: {
112-
type: "post",
113-
id: "1,2" <----- this!
114-
}
115-
}
116-
}
117-
}
118-
}
119-
*/
120-
```
121-
122-
This approach makes redux state updates a lot easier as during merge new string with IDs will replace the old one. Otherwise, it would require some extra efforts to delete outdated relationships from the store.
123-
12480
# Options
12581
## Endpoint And Metadata
12682
While using redux, it is supposed that cache is incrementally updated during the application lifecycle. However, you might face an issue if two different requests are working with the same data objects, and after normalization, it is not clear how to distinguish, which data objects are related to which request. json-api-normalizer can handle such situations by saving the API response structure as metadata, so you can easily get only data corresponding to the certain request.

0 commit comments

Comments
 (0)