Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Commit

Permalink
Merge d276a9d into d354a29
Browse files Browse the repository at this point in the history
  • Loading branch information
a1mersnow committed Apr 18, 2020
2 parents d354a29 + d276a9d commit b56b5b1
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions docs/api.md
Expand Up @@ -258,20 +258,17 @@ normalize(data, [patronsSchema]);

#### `fallbackStrategy` Usage
```js
const users = [
{ id: '1', name: "Emily", requestState: 'SUCCEEDED' },
{ id: '2', name: "Douglas", requestState: 'SUCCEEDED' }
];
const books = [
{id: '1', name: "Book 1", author: 1 },
{id: '2', name: "Book 2", author: 2 },
{id: '3', name: "Book 3", author: 3 }
]
const users = {
'1': { id: '1', name: "Emily", requestState: 'SUCCEEDED' },
'2': { id: '2', name: "Douglas", requestState: 'SUCCEEDED' }
};
const books = {
'1': {id: '1', name: "Book 1", author: 1 },
'2': {id: '2', name: "Book 2", author: 2 },
'3': {id: '3', name: "Book 3", author: 3 }
};

const authorSchema = new schema.Entity('authors');
const bookSchema = new schema.Entity('books', {
author: authorSchema
}, {
const authorSchema = new schema.Entity('authors', {}, {
fallbackStrategy: (key, schema) => {
return {
[schema.idAttribute]: key,
Expand All @@ -280,6 +277,14 @@ const bookSchema = new schema.Entity('books', {
};
}
});
const bookSchema = new schema.Entity('books', {
author: authorSchema
});

denormalize([1, 2, 3], [bookSchema], {
books,
authors: users
})

```

Expand Down

0 comments on commit b56b5b1

Please sign in to comment.