The reducer will take the data(either in array or object form) and parse it into a key value store. We call this store “cache”.
To insert one/many docoments:
insert("users", {user});
insert("posts", [array of posts])
To get any document from the store is as simple as calling state.cache.collections[id].
const user = cache.users["dkljfdfdfjhdf"];
const post = cache.posts["kd9kf9dkd9"];
If you want to index by a different field, you can pass it an index option:
insertOne("users", user, {index: "username"});
insertMany("posts", user, {index: "slug"});
Now you can get the by the index you named:
const user = cache.users["some_username"];
const post = cache.posts["some-title-slug"];
To join data in components:
const post = cache.posts["some-title-slug"];
post.user = cache.users[post.user_id];
gist here: