List params
Collection type
Resource type
Map the collection type into an array of resources.
This list is used to push the resources into the cache after loading from the collection, so we need to map it down to a list so we can cache everything.
Collection to read from.
Array of resources.
Create the SWR key for the given collection params.
List parameters to filter the API by.
SWR key for the collection.
Get the id for a given resource.
Resource to get the id for.
Id of the resource.
Remove a resource from a collection.
This can use defaultFilter
to remove a resource from
an array of resources, using the adapter
to match the id
.
Id of the resource to remove.
Collection to remove resource from.
Collection with resource removed.
Create the SWR key for the given resource or resource id.
The function has to handle both cases because there are methods
like delete
which don't have resources to act on but are given
ids. We need to be able to create the cache key for both cases.
Resource to create the key for.
SWR key for the resource.
Update or insert ("upsert") a resource in a collection.
This can use defaultUpsert
to pull the array of resources
and run it through the default logic for upserting a resource,
using the adapter
to match the id
.
Resource to upsert into the collection.
Collection to upsert into.
Upserted collection.
Generated using TypeDoc
Adapter for a resource.
Responsible for adapting a RESTful collections & resources into a common type. For a resource, it's responsible for determining the id of a given resource with the
id
method. For a collection, it's responsible for upserting or removing a resource from the collection, or adapting a collection to a common "array of resources" representation. This enables CRS to work flexibly for a variety of RESTful representations.