Create
addOne
accepts a single entity, and adds it.
addMany
accepts an array of entities or an object in the shape of Record <EntityId, T>, and adds them.
setAll
accepts an array of entities or an object in the shape of Record <EntityId, T>, and replaces the existing entity contents with the values in the array.
Read
selectIds
returns the state.ids array.
[]
selectEntities
returns the state.entities lookup table.
{}
selectAll
maps over the state.ids array, and returns an array of entities in the same order.
[]
SelectTortal
returns the total number of entities being stored in this state.
0
SelectById
given the state and an entity ID, returns the entity with that ID or undefined.
Update
updateOne
accepts an "update object" containing an entity ID and an object containing one or more new field values to update inside a changes field, and performs a shallow update on the corresponding entity.
updateMany
accepts an array of update objects, and performs shallow updates on all corresponding entities.
upsertOne
accepts a single entity. If an entity with that ID exists, it will perform a shallow update and the specified fields will be merged into the existing entity, with any matching fields overwriting the existing values. If the entity does not exist, it will be added.
upsertMany
accepts an array of entities or an object in the shape of Record<EntityId, T> that will be shallowly upserted.
Delete
removeOne
accepts a single entity ID value, and removes the entity with that ID if it exists.
removeMany
accepts an array of entity ID values, and removes each entity with those IDs if they exist.
Redux Store Tree
{ "entities": { "users": { "ids": [], "entities": {}, "status": 0 } }, "ui": { "form": { "status": 0 } } }