Utils
Model utils
fetchModelLink
fetchModelLink<T extends IJsonapiModel = IJsonapiModel>(
model: PureModel,
key: string,
requestHeaders?: IDictionary<string>,
options?: IRequestOptions,
): Promise<Response<T>>;
Fetch a link defined on a model.
fetchModelRefLink
function fetchModelRefLink<T extends IJsonapiModel = IJsonapiModel>(
model: PureModel,
ref: string,
key: string,
requestHeaders?: IDictionary<string>,
options?: IRequestOptions,
): Promise<Response<T>>;
Fetch a link defined on a model relationship.
getModelLinks
getModelLinks(model: PureModel): IDictionary<ILink>;
Get all links defined on a model.
getModelMeta
getModelMeta(model: PureModel): IDictionary<any>;
Get metadata defined on the model.
getModelRefLinks
getModelRefLinks(model: PureModel): IDictionary<IDictionary<ILink>>;
Get all links defined on a model relationship.
getModelRefMeta
getModelRefMeta(model: PureModel): IDictionary<any>;
Get metadata defined on a model relationship.
modelToJsonApi
modelToJsonApi(model: IJsonapiModel, onlyDirty?: boolean): IRecord;
Serialise the model into the JSON API format.
saveModel
saveModel(model: IJsonapiModel, options?: IRequestOptions): Promise<IJsonapiModel>;
Save the model to the server. Depending on the model state it will either be created or updated on the server.
saveRelationship
saveRelationship<T extends IJsonapiModel>(
model: T,
ref: string,
options?: IRequestOptions,
): Promise<T>;
Save the model relationship on the server.
getModelEndpointUrl
getModelEndpointUrl(model: IJsonapiModel, options?: IRequestOptions): string;
Get the URL that's used for API operations for that model.
Cache utils
clearAllCache
clearAllCache();
Clear the complete network cache.
clearCacheByType
clearCacheByType(type: IType);
Clear the network cache for the given model type.
isJsonApiClass
function isJsonApiClass(type: typeof PureModel | typeof Collection | typeof View): boolean;
Check if the given type is a JSON API class (was decorated with jsonapi()
).