Class: CacheStore<IsAsync>
Defined in: schemas/v2/cache/store.ts:104
Extends
CacheStoreShared<IsAsync,CacheItem<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:110
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"> & { convert: CacheStoreConvertOptions<{ id: null | string; type: "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook"; }>; } | 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(
items):IfAsync<IsAsync,void>
Defined in: schemas/v2/cache/store.ts:187
Parameters
| Parameter | Type |
|---|---|
items | { id: string; type: "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook"; }[] |
Returns
IfAsync<IsAsync, void>
Overrides
bulkGet()
bulkGet<
T>(items):IfAsync<IsAsync, (undefined| {id:string;value:CacheItem<T>; })[]>
Defined in: schemas/v2/cache/store.ts:177
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 | { id: string; value: CacheItem<T>; })[]>
Overrides
bulkPut()
bulkPut<
T>(items):IfAsync<IsAsync,void>
Defined in: schemas/v2/cache/store.ts:163
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(
type,id):If<IsAsync,Promise<void>,void>
Defined in: schemas/v2/cache/store.ts:140
Parameters
| Parameter | Type |
|---|---|
type | "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
id | string |
Returns
If<IsAsync, Promise<void>, void>
Overrides
edit()
edit<
T>(type,id,value):If<IsAsync,Promise<undefined|CacheItem<T>>,undefined|CacheItem<T>>
Defined in: schemas/v2/cache/store.ts:150
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:158
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:274
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:318
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 |
|---|---|
resourceType | T |
resourceId | string |
type | R |
Returns
If<IsAsync, Promise<{ id: string; type: R; }[]>, { id: string; type: R; }[]>
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:331
Type Parameters
| Type Parameter |
|---|
T extends keyof ItemMap |
Parameters
| Parameter | Type |
|---|---|
type | T |
relationships | { [R in never]?: null | (Pick<RelationDataItem<T, 1, true>, RelationshipFields<T>>[R]["data"] extends K ? NonNullable<K> extends unknown[] ? string[] : string : never) } |
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:380
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:236
Parameters
| Parameter | Type |
|---|---|
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"; }[] |
Returns
IfAsync<IsAsync, { id: string; type: "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook"; }[]>
put()
put<
T>(type,id,value):If<IsAsync,Promise<void>,void>
Defined in: schemas/v2/cache/store.ts:145
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(
request,path):IfAsync<IsAsync,void>
Defined in: schemas/v2/cache/store.ts:445
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
Parameters
| Parameter | Type | Description |
|---|---|---|
request | { body: null | WriteResourcePayload<Webhook, RequestMethod>; method: RequestMethod; } | The request data |
request.body | null | WriteResourcePayload<Webhook, RequestMethod> | - |
request.method | RequestMethod | - |
path | { id: string; mockAttributes?: Partial<{ DELETE: (body) => WriteResourceResponse<Webhook>; GET: (body) => WriteResourceResponse<Webhook>; PATCH: (body) => WriteResourceResponse<Webhook>; POST: (body) => WriteResourceResponse<Webhook>; }>; resource: Webhook; } | Path data extracted from the API route |
path.id | string | - |
path.mockAttributes? | Partial<{ DELETE: (body) => WriteResourceResponse<Webhook>; GET: (body) => WriteResourceResponse<Webhook>; PATCH: (body) => WriteResourceResponse<Webhook>; POST: (body) => WriteResourceResponse<Webhook>; }> | - |
path.resource | Webhook | - |
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:411
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:121
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:113
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>