fetchDatabaseChanges
Fetch changed record zones in the database.
Declaration
Promise< CloudKit.DatabaseChangesResponse, CKError > fetchDatabaseChanges(
optional Object options
);Parameters
- options:
Options to fetch database changes. This
Dictionaryobject has one key:Key
Description
syncTokenIdentifies a point in the database’s change history. The first time you fetch changes, omit this key and if
moreComingistruein the response, use thesyncTokenin the response in the next request untilmoreComingisfalse.
Return Value
A Promise object that resolves to a CloudKit.DatabaseChangesResponse object, or rejects to a CKError object.
Discussion
For example, use this method to fetch the zones that changed and then use the fetchRecordZoneChanges method to fetch the changed records in each zone.
database.fetchDatabaseChanges().then(function(response) {
return database.fetchRecordZoneChanges(response.zones)
})
.then(function(response) {
response.zones.forEach(function(zone) {
zone.records.forEach(function(record) {
// Apply the record change
})
})
})