Class: CacheStore<IsAsync>
Defined in: schemas/v2/cache/store.ts:96
Extends
CacheStoreShared<IsAsync,CacheItem<ItemType>, {id:string;type:ItemType; }>
Type Parameters
| Type Parameter |
|---|
IsAsync extends boolean |
Constructors
Constructor
new CacheStore<
IsAsync>(async,binding?,options?):CacheStore<IsAsync>
Defined in: schemas/v2/cache/store.ts:102
Parameters
| Parameter | Type |
|---|---|
async | IsAsync |
binding? | CacheStoreBinding<IsAsync, CacheItem<"address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook">> |
options? | CacheStoreOptions |
Returns
CacheStore<IsAsync>
Overrides
Properties
| Property | Modifier | Type | Description | Overrides | Inherited from |
|---|---|---|---|---|---|
binding | public | CacheStoreBinding<IsAsync, CacheItem<"address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook">> | - | - | CacheStoreShared.binding |
options | public | Required<Omit<CacheStoreOptions, "events" | "initial">> & Pick<CacheStoreOptions, "events"> & Required<Pick<CacheStoreSharedOptions<{ id: string; type: "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook"; }>, "convert">> | Options for the cache. Can be used to control how the cache behaves on edits or other options for custom cache items. | CacheStoreShared.options | - |
Methods
bulkDelete()
bulkDelete(
keys):If<IsAsync,Promise<void>>
Defined in: schemas/v2/cache/shared.ts:139
Parameters
| Parameter | Type |
|---|---|
keys | { id: string; type: "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook"; }[] |
Returns
If<IsAsync, Promise<void>>
Inherited from
bulkGet()
bulkGet<
T>(items):IfAsync<IsAsync, (undefined| {key:string;value:CacheStoreItem<T>; })[]>
Defined in: schemas/v2/cache/store.ts:165
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
Parameters
| Parameter | Type |
|---|---|
items | { id: string; type: T; }[] |
Returns
IfAsync<IsAsync, (undefined | { key: string; value: CacheStoreItem<T>; })[]>
Overrides
bulkPut()
bulkPut<
T>(items):IfAsync<IsAsync,void>
Defined in: schemas/v2/cache/store.ts:151
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
Parameters
| Parameter | Type |
|---|---|
items | CacheStoreItem<T>[] |
Returns
IfAsync<IsAsync, void>
Overrides
delete()
delete(...
args):If<IsAsync,Promise<void>>
Defined in: schemas/v2/cache/shared.ts:70
Parameters
| Parameter | Type |
|---|---|
...args | ["address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook", string] |
Returns
If<IsAsync, Promise<void>>
Inherited from
deleteAll()
deleteAll():
If<IsAsync,Promise<void>>
Defined in: schemas/v2/cache/shared.ts:65
Returns
If<IsAsync, Promise<void>>
Inherited from
edit()
edit<
T>(type,id,value):If<IsAsync,Promise<undefined|CacheItem<T>>,undefined|CacheItem<T>>
Defined in: schemas/v2/cache/store.ts:139
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
Parameters
| Parameter | Type |
|---|---|
type | T |
id | string |
value | Partial<ItemMap[T]> |
Returns
If<IsAsync, Promise<undefined | CacheItem<T>>, undefined | CacheItem<T>>
Overrides
get()
get<
T>(type,id):If<IsAsync,Promise<undefined|CacheItem<T>>,undefined|CacheItem<T>>
Defined in: schemas/v2/cache/store.ts:146
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
Parameters
| Parameter | Type |
|---|---|
type | T |
id | string |
Returns
If<IsAsync, Promise<undefined | CacheItem<T>>, undefined | CacheItem<T>>
Overrides
getRelated()
getRelated<
T,R>(type,id,related):IfAsync<IsAsync,undefined|null| {items: {id:string;value:undefined|CacheItem<RelationshipFieldToFieldType<T,R>>; }[];type:"item"; } | {items: {id:string;value:undefined|CacheItem<RelationshipFieldToFieldType<T,R>>; }[];type:"array"; }>
Defined in: schemas/v2/cache/store.ts:237
Get the item(s) in a resource for a relationship
Type Parameters
| Type Parameter |
|---|
T extends keyof ItemMap |
R extends never |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | T | The type of the resource |
id | string | The id of the resource |
related | R | The relation name to get |
Returns
IfAsync<IsAsync, undefined | null | { items: { id: string; value: undefined | CacheItem<RelationshipFieldToFieldType<T, R>>; }[]; type: "item"; } | { items: { id: string; value: undefined | CacheItem<RelationshipFieldToFieldType<T, R>>; }[]; type: "array"; }>
undefinedwhen the resource is not foundnullwhen the relationship is not defined on the resourceitemscan have undefined items, that item is not in the cache found.
getRelatedToResource()
getRelatedToResource<
T,R>(resourceType,resourceId,type):If<IsAsync,Promise<{id:string;type:R; }[]>, {id:string;type:R; }[]>
Defined in: schemas/v2/cache/store.ts:289
Get all items in the cache related to an item. If no list method is present on the binding, an empty array will always be returned.
Type Parameters
| Type Parameter |
|---|
T extends keyof ItemMap |
R extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
Parameters
| Parameter | Type | Description |
|---|---|---|
resourceType | T | The type of the original item |
resourceId | string | The id of the original item |
type | R | The type of the related items to search |
Returns
If<IsAsync, Promise<{ id: string; type: R; }[]>, { id: string; type: R; }[]>
A list of type resources
getRelationships()
getRelationships<
T>(type,relationships):IfAsync<IsAsync,Relationship<T,RelationshipFields<T>> & {items:{ [R in never]: { id: string; item: CacheItem<RelationshipFieldToFieldType<T, R>>; type: RelationshipFieldToFieldType<T, R> } }[RelationshipFields<T>][]; }>
Defined in: schemas/v2/cache/store.ts:302
Type Parameters
| Type Parameter |
|---|
T extends keyof ItemMap |
Parameters
| Parameter | Type |
|---|---|
type | T |
relationships | StringifiedRelationships<T, RelationshipFields<T>> |
Returns
IfAsync<IsAsync, Relationship<T, RelationshipFields<T>> & { items: { [R in never]: { id: string; item: CacheItem<RelationshipFieldToFieldType<T, R>>; type: RelationshipFieldToFieldType<T, R> } }[RelationshipFields<T>][]; }>
getResource()
getResource<
T>(type,id):IfAsync<IsAsync,undefined| {data: {attributes:Partial<ItemMap[T]>; } &Relationship<T,RelationshipFields<T>>;included:{ [R in never]: { id: string; item: CacheItem<RelationshipFieldToFieldType<T, R>>; type: RelationshipFieldToFieldType<T, R> } }[RelationshipFields<T>][]; }>
Defined in: schemas/v2/cache/store.ts:348
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
Parameters
| Parameter | Type |
|---|---|
type | T |
id | string |
Returns
IfAsync<IsAsync, undefined | { data: { attributes: Partial<ItemMap[T]>; } & Relationship<T, RelationshipFields<T>>; included: { [R in never]: { id: string; item: CacheItem<RelationshipFieldToFieldType<T, R>>; type: RelationshipFieldToFieldType<T, R> } }[RelationshipFields<T>][]; }>
list()
list(
options):IfAsync<IsAsync, {id:string;type:"address"|"benefit"|"campaign"|"client"|"deliverable"|"goal"|"media"|"member"|"post"|"pledge-event"|"tier"|"user"|"webhook"; }[]>
Defined in: schemas/v2/cache/store.ts:195
List all resources (with certain relationships) of a resource type If the binding has no list method implemented, an empty array is always returned.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | { relationships: { id: null | string; type: "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook"; }[]; type: "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook"; }[] | The resources to list, optionally with required relationships to other resources/ types. |
Returns
IfAsync<IsAsync, { id: string; type: "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook"; }[]>
The matched ids + type combinations for the resources in the cache.
put()
put<
T>(type,id,value):If<IsAsync,Promise<void>,void>
Defined in: schemas/v2/cache/store.ts:135
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
Parameters
| Parameter | Type |
|---|---|
type | T |
id | string |
value | CacheItem<T> |
Returns
If<IsAsync, Promise<void>, void>
Overrides
syncRequest()
syncRequest<
R,T>(request,path):IfAsync<IsAsync,void>
Defined in: schemas/v2/cache/store.ts:413
Sync the request body to the cache, updating the resource with the changes. For the following methods actions are done:
DELETE: delete the resource in the cachePATCH: updates the resource (attributes and relationships)POST: creates the resource in the cache
Type Parameters
| Type Parameter | Default type |
|---|---|
R extends RequestMethod | RequestMethod |
T extends Webhook | Webhook |
Parameters
| Parameter | Type | Description |
|---|---|---|
request | { body: null | WriteResourcePayload<T, R>; method: R; } | The request data |
request.body | null | WriteResourcePayload<T, R> | - |
request.method | R | - |
path | { id: string; mockAttributes?: Partial<{ DELETE: (body) => WriteResourceResponse<T>; GET: (body) => WriteResourceResponse<T>; PATCH: (body) => WriteResourceResponse<T>; POST: (body) => WriteResourceResponse<T>; }>; resource: T; } | Path data extracted from the API route |
path.id | string | - |
path.mockAttributes? | Partial<{ DELETE: (body) => WriteResourceResponse<T>; GET: (body) => WriteResourceResponse<T>; PATCH: (body) => WriteResourceResponse<T>; POST: (body) => WriteResourceResponse<T>; }> | - |
path.resource | T | - |
Returns
IfAsync<IsAsync, void>
Throws
when path.id is null. For POST requests, use the new id as path id
Throws
when the request body is null for non-DELETE requests
Throws
when options.requests.syncOptions.requireMockAttributes is true and no mock attributes are generated.
syncResource()
syncResource<
T,R>(attributeItem):IfAsync<IsAsync,void>
Defined in: schemas/v2/cache/store.ts:379
Synchronize a resource with the cache. This method is used by syncRequest
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
R extends never |
Parameters
| Parameter | Type | Description |
|---|---|---|
attributeItem | AttributeItem<T, Partial<ItemMap[T]>> & Partial<Relationship<T, R>> | The item with attributes (and relationships) |
Returns
IfAsync<IsAsync, void>
a promise for async storage
createAsync()
staticcreateAsync<Value,Store>(store,binding?,options?):InstanceType<Store>
Defined in: schemas/v2/cache/shared.ts:162
Type Parameters
| Type Parameter |
|---|
Value |
Store extends typeof CacheStoreShared |
Parameters
| Parameter | Type |
|---|---|
store | Store |
binding? | CacheStoreBinding<true, Value> |
options? | Partial<Store["prototype"]["options"]> |
Returns
InstanceType<Store>
Inherited from
createSync()
staticcreateSync<Value,Store>(store,binding?,options?):InstanceType<Store>
Defined in: schemas/v2/cache/shared.ts:154
Type Parameters
| Type Parameter |
|---|
Value |
Store extends typeof CacheStoreShared |
Parameters
| Parameter | Type |
|---|---|
store | Store |
binding? | CacheStoreBinding<false, Value> |
options? | Partial<Store["prototype"]["options"]> |
Returns
InstanceType<Store>