---
title: "perform(_:inZoneWith:completionHandler:)"
framework: cloudkit
role: symbol
role_heading: Instance Method
path: "cloudkit/ckdatabase/perform(_:inzonewith:completionhandler:)"
---

# perform(_:inZoneWith:completionHandler:)

Searches for records matching a predicate in the specified record zone.

## Declaration

```swift
func perform(_ query: CKQuery, inZoneWith zoneID: CKRecordZone.ID?, completionHandler: @escaping @Sendable ([CKRecord]?, (any Error)?) -> Void)
```

## Parameters

- `query`: The query that contains the search parameters. For more information, see doc://com.apple.cloudkit/documentation/CloudKit/CKQuery.
- `zoneID`: The identifier of the record zone to search. If you’re searching a shared database, provide a record zone identifier; otherwise, you can specify nil to search all record zones in the database.
- `completionHandler`: The closure to execute with the search results.

## Discussion

Discussion The completion handler takes the following parameters: The records that match the specified query, or nil if there’s an error. An error if a problem occurs, or nil if CloudKit completes the search successfully. For information on a more convenient way to search a database, see records(matching:inZoneWith:desiredKeys:resultsLimit:).

## See Also

### Querying Records

- [records(matching:inZoneWith:desiredKeys:resultsLimit:)](cloudkit/ckdatabase/records(matching:inzonewith:desiredkeys:resultslimit:).md)
- [records(continuingMatchFrom:desiredKeys:resultsLimit:)](cloudkit/ckdatabase/records(continuingmatchfrom:desiredkeys:resultslimit:).md)
- [fetch(withQuery:inZoneWith:desiredKeys:resultsLimit:completionHandler:)](cloudkit/ckdatabase/fetch(withquery:inzonewith:desiredkeys:resultslimit:completionhandler:).md)
- [fetch(withCursor:desiredKeys:resultsLimit:completionHandler:)](cloudkit/ckdatabase/fetch(withcursor:desiredkeys:resultslimit:completionhandler:).md)
- [records(matching:inZoneWith:)](cloudkit/ckdatabase/records(matching:inzonewith:).md)
