---
title: "fetchDatabaseChanges(since:resultsLimit:completionHandler:)"
framework: cloudkit
role: symbol
role_heading: Instance Method
path: "cloudkit/ckdatabase/fetchdatabasechanges(since:resultslimit:completionhandler:)"
---

# fetchDatabaseChanges(since:resultsLimit:completionHandler:)

Fetches all modified record zones and delivers them to a completion handler.

## Declaration

```swift
@preconcurrency func fetchDatabaseChanges(since changeToken: CKServerChangeToken?, resultsLimit: Int? = nil, completionHandler: @escaping @Sendable (Result<(modifications: [CKDatabase.DatabaseChange.Modification], deletions: [CKDatabase.DatabaseChange.Deletion], changeToken: CKServerChangeToken, moreComing: Bool), any Error>) -> Void)
```

## Parameters

- `changeToken`: The change token from the previous execution of this method. If this is your app’s first fetch, or you want to refetch every change in the database’s history, specify nil.
- `resultsLimit`: The maximum number of changes to return. The server may use a limit lower than this value.
- `completionHandler`: The closure to execute with the fetch results.

## Discussion

Discussion The completion handler takes a single Result parameter that contains either a tuple, or an error if the request fails. For example, when the network is unavailable or the device doesn’t have an active iCloud account. When present, the tuple contains the following named elements: This method fetches record zone changes in a database, which includes new record zones, changed zones — including deleted or purged zones — and zones that contain record changes. Along with the fetched changes, CloudKit supplies a change token, which is an opaque token that denotes a specific point in the database’s history. Store this token and provide it the next time you execute this method. Change tokens conform to NSSecureCoding and are safe to cache on-disk. Don’t infer any behavior or order from a token’s contents. For information on a more configurable way to fetch database changes, see CKFetchDatabaseChangesOperation.

## See Also

### Fetching Changes

- [databaseChanges(since:resultsLimit:)](cloudkit/ckdatabase/databasechanges(since:resultslimit:).md)
- [CKDatabase.DatabaseChange](cloudkit/ckdatabase/databasechange.md)
- [recordZoneChanges(inZoneWith:since:desiredKeys:resultsLimit:)](cloudkit/ckdatabase/recordzonechanges(inzonewith:since:desiredkeys:resultslimit:).md)
- [fetchRecordZoneChanges(inZoneWith:since:desiredKeys:resultsLimit:completionHandler:)](cloudkit/ckdatabase/fetchrecordzonechanges(inzonewith:since:desiredkeys:resultslimit:completionhandler:).md)
- [CKDatabase.RecordZoneChange](cloudkit/ckdatabase/recordzonechange.md)
