DataStore
The DataStore class is used to find, create, update, remove, count and group entities in a collection.
Static Method Summary
Static Public Methods | ||
public static |
clearCache(): Promise<Object> Clear the cache. |
|
public static |
collection(collection: string, type: DataStoreType): DataStore Returns an instance of th DataStore class based on the type provided. |
Method Summary
Public Methods | ||
public |
Remove all entities in the collection that are stored in the local cache. |
|
public |
Clear pending sync items from the sync queue. |
|
public |
Count all entities in the collection. |
|
public |
Create a single entity on the collection. |
|
public |
Find all entities in the collection. |
|
public |
Find a single entity in the collection by id. |
|
public |
group(aggregationQuery: Aggregation): Observable Group entities. |
|
public |
pendingSyncCount(query: Query): Promise Count the number of entities waiting to be pushed to the backend. |
|
public |
pendingSyncEntities(query: Query): Promise Retrieve the entities waiting to be pushed to the backend. |
|
public |
Pull entities from the backend and save them to the local cache |
|
public |
Push pending sync items to the backend. |
|
public |
Remove all entities in the data store. |
|
public |
removeById(id: string): Promise Remove a single entity in the data store by id. |
|
public |
Save a single entity on the data store. |
|
public |
Sync items with the backend. |
|
public |
Update a single entity on the data store. |
Static Public Methods
public static clearCache(): Promise<Object> source
Clear the cache. This will delete all data in the cache.
public static collection(collection: string, type: DataStoreType): DataStore source
Returns an instance of th DataStore class based on the type provided.
Params:
Name | Type | Attribute | Description |
collection | string |
|
Name of the collection. |
type | DataStoreType |
|
Type of store to return. |
Public Methods
public clear(query: Query): Promise source
Remove all entities in the collection that are stored in the local cache.
Params:
Name | Type | Attribute | Description |
query | Query |
|
Query used to filter entities. |
public clearSync(query: Query): Promise source
Clear pending sync items from the sync queue.
Params:
Name | Type | Attribute | Description |
query | Query | Query used to clear a subset of pending sync items |
public count(query: Query, options: Object): Observable source
Count all entities in the collection. A query can be optionally provided to return a subset of all entities in a collection or omitted to return all entities in a collection. The number of entities returned adheres to the limits specified at http://devcenter.kinvey.com/rest/guides/datastore#queryrestrictions.
Return:
Observable | Observable. |
public create(entity: Object): Promise source
Create a single entity on the collection.
Params:
Name | Type | Attribute | Description |
entity | Object | Entity that you want to create on the collection. |
Throw:
Unable to create an array of entities. |
public find(query: Query, options: Object): Observable source
Find all entities in the collection. A query can be optionally provided to return a subset of all entities in a collection or omitted to return all entities in a collection. The number of entities returned adheres to the limits specified at http://devcenter.kinvey.com/rest/guides/datastore#queryrestrictions.
Return:
Observable | Observable. |
public findById(id: string, options: Object): Observable source
Find a single entity in the collection by id.
Return:
Observable | Observable. |
public group(aggregationQuery: Aggregation): Observable source
Group entities.
Params:
Name | Type | Attribute | Description |
aggregationQuery | Aggregation | Aggregation used to group entities. |
Return:
Observable | Observable. |
public pendingSyncCount(query: Query): Promise source
Count the number of entities waiting to be pushed to the backend.
Params:
Name | Type | Attribute | Description |
query | Query |
|
Query to count a subset of entities. |
public pendingSyncEntities(query: Query): Promise source
Retrieve the entities waiting to be pushed to the backend.
Params:
Name | Type | Attribute | Description |
query | Query |
|
Query to count a subset of entities. |
public pull(query: Query, options: Object): Promise<number> source
Pull entities from the backend and save them to the local cache
IMPORTANT: This method is not intended to be used to make concurrent requests. If you wish to pull multiple pages, please use the autoPagination option
public remove(query: Query): Promise source
Remove all entities in the data store. A query can be optionally provided to remove a subset of all entities in a collection or omitted to remove all entities in a collection. The number of entities removed adheres to the limits specified at http://devcenter.kinvey.com/rest/guides/datastore#queryrestrictions.
Params:
Name | Type | Attribute | Description |
query | Query |
|
Query used to filter entities. |
public removeById(id: string): Promise source
Remove a single entity in the data store by id.
Params:
Name | Type | Attribute | Description |
id | string | Entity by id to remove. |
public save(entity: Object): Promise source
Save a single entity on the data store.
Params:
Name | Type | Attribute | Description |
entity | Object | Entity that you want to save on the collection. |
public sync(query: Query, options: Object): Promise<{push: [], pull: number}>{push:> source
Sync items with the backend. This will push pending sync items first and then pull items from the backend and save them to the local cache.
public update(entity: Object): Promise source
Update a single entity on the data store.
Params:
Name | Type | Attribute | Description |
entity | Object | Entity that you want to update on the collection. |
Throw:
Unable to update an array of entities. |
|
The entity provided does not contain an _id. An _id is required to update the entity. |