You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
Copy file name to clipboardexpand all lines: README.md
+109-5
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,8 @@ Pre-requisites:
20
20
* via nu-get, install the following packages:
21
21
* Newtonsoft.json
22
22
* SQLite.Net-PCL
23
-
* SQLite.Net.Platform.* where * is the runtime for the current application
23
+
* SQLite.Net.Platform.* (where * is the runtime for the current application)
24
+
* LinqExtender
24
25
25
26
26
27
@@ -41,12 +42,11 @@ This library is implemented with a clean separation between blocking synchronous
41
42
Client kinveyClient = new Client.Builder(appKey, appSecret).build();
42
43
43
44
##### add offline to the client builder
44
-
Note the addition of two new builder methods (which will be refactored and simplified) to add the local database path location as well as a platform specific implementation of the sqlite.net pcl.
45
+
Note the addition of two new builder methods to add the local database path location as well as a platform specific implementation of the sqlite.net pcl.
45
46
46
47
kinveyClient = new Client.Builder(appKey, appSecret)
@@ -98,6 +98,110 @@ Note the addition of two new builder methods (which will be refactored and simpl
98
98
});
99
99
}
100
100
});
101
+
102
+
### Querying
103
+
104
+
Querying can be performed through standard LINQ operators, where an instance of `AppData` can be used as the queryable object. The Kinvey library provides a subset of LINQ which includes most of the core functionality. For example, you cannot perform Join operations due to the nature of a nosql datastore. The library does support Lambda operations, as well as sorting, where clauses, and logical operators.
105
+
106
+
For example, a query to get all Entites where a field called `last name` is equal to `smith` can be written as follows:
Caching functionality is provided as in-memory implementation, meaning that cached data will only be available per use of the application. Offline functionality utilizes SQLite to maintain a local copy of entities, as well as a queue of pending requests. This data is persisted between uses of the application, and will perform any queued up requests once any request has been successfully completed.
123
+
124
+
Both features are accessed through very similar methods on an Appdata instance, essentially only requiring an implementation of a `Store`, as well as a Policy to use. See below for details about the provided caching and offline policies.
125
+
126
+
Both caching and offline can be used at the same time, allowing for very quick responses to commonly repeated requests, and a fail-over in case a network connection is lost.
127
+
128
+
####Enabling Caching and Offline
129
+
130
+
The Client.Builder will require both a reference to the local filesystem, as well as a platform specific implementation of the SQLite.Net-PCL. For Android, the following will store the database in private local storage:
131
+
132
+
kinveyClient = new Client.Builder(appKey, appSecret)
*`CachePolicy.NOCACHE` - This policy will not use any caching, and will execute every request online.
162
+
163
+
Use this policy if your application is dependant on data that is shared between multiple users and always needs to be up to date.
164
+
165
+
166
+
*`CachePolicy.CACHEONLY` - This policy will only retrieve data from the cache, and will not use any network connection.
167
+
168
+
Use this policy in combination with another policy, to allow for quick response times without requiring a network connection for specific operations.
169
+
170
+
171
+
*`CachePolicy.CACHEFIRST` - This policy will first attempt to retrieve data from the cache. If the data has been cached, it will be returned. If the data does not exist in the cache, the data will be retrieved from Kinvey's Backend and the cache will be updated.
172
+
173
+
Use this policy if your application can display data that doesn't change very often but you still want local updates.
174
+
175
+
176
+
*`CachePolicy.CACHEFIRST_NOREFRESH` - This policy will first attempt to retrieve data from the cache. If the data has been cached, it will be returned. If the data does not exist in the cache, the data will be retrieved from Kinvey's Backend but the cache will not be updated with the new results.
177
+
178
+
Use this policy if you want to set default results, however if a request is made that cannot return these defaults a live request will be made (without modifying those default values)
179
+
180
+
181
+
*`CachePolicy.NETWORKFIRST` - This policy will execute the request on the network, and will store the result in the cache. If the online execution fails, the results will be pulled from the cache.
182
+
183
+
Use this policy if you application wants the latest data but you still want responsiveness if a connection is lost
184
+
185
+
186
+
187
+
###Offline Policies
188
+
189
+
190
+
*`OfflinePolicy.ONLINE_FIRST` - This policy will attempt to execute the request online first, and if that is successful will update the local store with the results. If the request fails due to connectivity issues, then the request will be executed against the local store. If it fails for any other reason such as an Authorization Error, the onFailure callback will be called.
191
+
192
+
Use this policy if your application's data is constantly changing on the backend, but you want to support offline mode.
193
+
194
+
195
+
*`OfflinePolicy.LOCAL_FIRST` - This policy will attempt to execute the request against the local store first. If the request is a Get, and the data cannot be found in the local store, then an online request will be attempted. If that suceeds, the store will be updated, and onSuccess will be called. If that fails, then onFailure will be called. For save requests, the local store will be updated and the entity will be returned through the onSuccess callback.
196
+
197
+
Use this policy if each user has their own data, and updates are not constantly required from your backend.
198
+
199
+
200
+
*`OfflinePolicy.ALWAYS_ONLINE` - This policy will not use any local storage or queueing, and will execute every request online. If no network connection is available, errors will be returned through the onFailure callback.
201
+
202
+
Use this policy if your application is fully dependant on data in the backend, and data cannot be stored locally.
0 commit comments