As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Hello James,
I am not sure which Kinvey SDK you are using. Thanks for confirming that you are using Cache datastore. You use Cache datastore when you want the data stored on the device to optimize your app’s performance and/or provide offline support for short periods of network loss. This is the default DataStore type if a type is not explicitly set.
Please check this link and the example is given on it. Following are a few points which will provide you with a better understanding of the concept:
the entity will first be saved to cache and then to the backend. If you do not have a network connection, the entity will be stored locally. You will need to push it to the server when network reconnects, using 'dataStore.push()' method.
If you have "_id" value of the entity then you can use 'dataStore.findById('entity-id')' method as mentioned on this link.
Thanks,
Pranav
Kinvey
James,
If you have wanted to fetch ALL the entities from the cache, you can use the following code snippet:
var stream = dataStore.find(); stream.subscribe(function onNext(entities) { // ... }, function onError(error) { // ... }, function onComplete() { // ... });
If you don't want to fetch all the entities but a few, then you will have to use a 'query'. To fetch multiple entities using a query, call dataStore.find and pass in a query as follows:
var query = new Kinvey.Query(); query.equalTo('field', 'value'); var stream = dataStore.find(query); stream.subscribe(function onNext(entities) { // ... }, function onError(error) { // ... }, function onComplete() { // ... });
For more explanation about Kinvey Querying, please check this link.
Thanks,
Pranav
Kinvey
James,
If you implement the suggestions given in my earlier comment, then you will notice that it returns the entities from cache with "_id" property along with other properties.
If you just want to retrieve the "id" value of the entities, then you will have to use Field Selection explained on this link. You will have to include all the properties while updating an entity. Saving entities after retrieving them using Field Selection will result in the loss of all fields not selected. Currently, there is no way to pass only the attributes you want to be changed. The backend stores the entire JSON body as passed in the request body.
I request you to implement all the method to get a better understanding.
Thanks,
Pranav
Kinvey
jamesnicholls11@gmail.com
Hi,
I'm writing a small app to test out Kinvey.
Given a device is offline and the app is using a Cache datastore, when I call datastore.save(entity), the returned promise rejects. However I can see in the browser's local DB that the entity has been successfully stored locally and an ID generated from it.
Is there a way I can retrieve the generated ID of the entity so my app can continue to interact with it whilst the application is offline?
Thanks,
James