<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "CloudKitJS",
  "identifier" : "/documentation/CloudKitJS/CloudKit.Database/fetchRecords",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "CloudKit JS"
    ],
    "preciseIdentifier" : "instm/CloudKit.Database/fetchRecords"
  },
  "title" : "fetchRecords"
}
-->

# fetchRecords

Fetches one or more records.

```
Promise<CloudKit.RecordsResponse, CloudKit.CKError> fetchRecords(
	CloudKit.Record|CloudKit.Record[]|String|String[] records,
	optional Object options
);
```

## Parameters

`records`

Possible values are:
    
    |Type                                                                   |Description                                                                                                                                                   |
    |-----------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
    |``doc://com.apple.cloudkitjs/documentation/CloudKitJS/CloudKit.Record``|A dictionary record to fetch. Only the `recordName` key is required in the ``doc://com.apple.cloudkitjs/documentation/CloudKitJS/CloudKit.Record`` dictionary.|
    |`CloudKit.Record[]`                                                    |An array of records to fetch.                                                                                                                                 |
    |`String`                                                               |The name of a record to fetch.                                                                                                                                |
    |`String[]`                                                             |An array of names of records to fetch.                                                                                                                        |

`options`

A dictionary containing options to use when fetching records. Possible dictionary keys are:
    
    |Key               |Description                                                                                                                                                                                                                         |
    |------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    |`zoneID`          |A ``doc://com.apple.cloudkitjs/documentation/CloudKitJS/CloudKit.ZoneID`` or zone name (`String`) that identifies the record zone in the database where you want to perform the operation. The default is the database default zone.|
    |`desiredKeys`     |An array of strings containing record field names that limits the amount of data returned in this operation. Only the fields specified in the array are returned. The default is `null`, which fetches all record fields.           |
    |`numbersAsStrings`|A Boolean value indicating whether number fields should be represented by strings. The default value is `false`.                                                                                                                    |

## Return Value

A `Promise` object that resolves to a [`CloudKit.RecordsResponse`](/documentation/CloudKitJS/CloudKit.RecordsResponse) object if the operation succeeds; otherwise, a [`CKError`](/documentation/CloudKitJS/CloudKit/CKError) object.

## Discussion

To get the fetched record, use the [`records`](/documentation/CloudKitJS/CloudKit.RecordsResponse/records) property in the [`CloudKit.RecordsResponse`](/documentation/CloudKitJS/CloudKit.RecordsResponse) class.

```javascript
database.fetchRecords('115').then(function(response) {
    if (response.hasErrors) {
        // Insert error handling
        throw response.errors[0];
    } else {
        // Insert successfully fetched record
        var fetchedRecord = response.records[0];
    }
});
```

Similar to the [`saveRecords`](/documentation/CloudKitJS/CloudKit.Database/saveRecords) method, if you don’t specify a zone ID in the `options` parameter, the records are fetched from the default zone. To fetch records from a specific zone, pass a dictionary with the `zoneID` key set to the name of your zone.

```javascript
database.fetchRecords('115', { zoneID: 'myZone' }).then(function(response) {
    // …
}
```

---

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)