<!--
{
  "availability" : [
    "iOS: 15.0.0 - 15.0.0",
    "iPadOS: 15.0.0 - 15.0.0",
    "macCatalyst: 15.0.0 - 15.0.0",
    "macOS: 12.0.0 - 12.0.0",
    "tvOS: 15.0.0 - 15.0.0",
    "visionOS: -",
    "watchOS: 8.0.0 - 8.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CloudKit",
  "identifier" : "/documentation/CloudKit/CKDatabase/records(matching:inZoneWith:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "CloudKit"
    ],
    "preciseIdentifier" : "s:So10CKDatabaseC8CloudKitE7records8matching10inZoneWithSaySo8CKRecordCGSo7CKQueryC_So0iG2IDCSgtYaKF"
  },
  "title" : "records(matching:inZoneWith:)"
}
-->

# records(matching:inZoneWith:)

Searches for records in the specified record zone and returns them to an awaiting caller.

```
func records(matching query: CKQuery, inZoneWith zoneID: CKRecordZone.ID?) async throws -> [CKRecord]
```

## Parameters

`query`

The query that contains the search parameters. For more information, see [`CKQuery`](/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.

## Return Value

An array of records that match the specified query.

## Discussion

For information on a more configurable way to search a database, see [`CKQueryOperation`](/documentation/CloudKit/CKQueryOperation).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)