Store
The Store class defines a local data store, and provides methods to
retrieve data from the API.
Constructor Summary
| Public Constructor | ||
| public |
|
|
Member Summary
| Public Members | ||
| public |
The model registry. |
|
| Protected Members | ||
| protected |
The local data store. |
|
Method Summary
| Public Methods | ||
| public |
Get all loaded records of a specific type. |
|
| public |
createRecord(type: String, data: Object): Model Create a new record of the given type. |
|
| public |
Make a request to the API to find record(s) of a specific type. |
|
| public |
Get a record from the store by the value of a model attribute. |
|
| public |
Get a record from the store by ID. |
|
| public |
pushObject(data: Object): Model | null Create a model to represent a resource object (or update an existing one), and push it into the store. |
|
| public |
pushPayload(payload: Object): Model | Model[] Push resources contained within an API payload into the store. |
|
| public |
Remove the given model from the store. |
|
Public Constructors
public constructor() source
Public Members
public models: Object source
The model registry. A map of resource types to the model class that should be used to represent resources of that type.
Protected Members
Public Methods
public all(type: String): Model[] source
Get all loaded records of a specific type.
Params:
| Name | Type | Attribute | Description |
| type | String |
public createRecord(type: String, data: Object): Model source
Create a new record of the given type.
public find(type: String, id: Integer | Integer[] | Object, query: Object, options: Object): Promise source
Make a request to the API to find record(s) of a specific type.
public getBy(type: String, key: String, value: *): Model source
Get a record from the store by the value of a model attribute.
public getById(type: String, id: Integer): Model source
Get a record from the store by ID.
Params:
| Name | Type | Attribute | Description |
| type | String | The resource type. |
|
| id | Integer | The resource ID. |
public pushObject(data: Object): Model | null source
Create a model to represent a resource object (or update an existing one), and push it into the store.
Params:
| Name | Type | Attribute | Description |
| data | Object | The resource object |
Reference
Source
