---
title: "modifyRecords(saving:deleting:savePolicy:atomically:)"
framework: cloudkit
role: symbol
role_heading: Instance Method
path: "cloudkit/ckdatabase/modifyrecords(saving:deleting:savepolicy:atomically:)"
---

# modifyRecords(saving:deleting:savePolicy:atomically:)

Modifies the specified records and returns the results to an awaiting caller.

## Declaration

```swift
func modifyRecords(saving recordsToSave: [CKRecord], deleting recordIDsToDelete: [CKRecord.ID], savePolicy: CKModifyRecordsOperation.RecordSavePolicy = .ifServerRecordUnchanged, atomically: Bool = true) async throws -> (saveResults: [CKRecord.ID : Result<CKRecord, any Error>], deleteResults: [CKRecord.ID : Result<Void, any Error>])
```

## Parameters

- `recordsToSave`: The records to save.
- `recordIDsToDelete`: The identifiers of the records to permanently delete.
- `savePolicy`: The policy to use when modifying existing records. For possible values, see doc://com.apple.cloudkit/documentation/CloudKit/CKModifyRecordsOperation/RecordSavePolicy.
- `atomically`: If doc://com.apple.documentation/documentation/Swift/true, the entire operation fails if CloudKit can’t modify one or more of the specified records; otherwise, CloudKit reports individual failures in the returned tuple. Atomic changes are only applicable in record zones that have the doc://com.apple.cloudkit/documentation/CloudKit/CKRecordZone/Capabilities-swift.struct/atomic capability.

## Return Value

Return Value A tuple with the following named elements:

## Discussion

Discussion Deleting records may cause additional deletions if other records in the database reference the deleted records. CloudKit doesn’t provide the identifiers of any additional records it deletes. This method throws an error if the request fails, such as when the network is unavailable or the device doesn’t have an active iCloud account, or when atomically is true and one or more of the specified changes fail; otherwise, the returned tuple includes any individual record errors. For information on a more configurable way to modify records, see CKModifyRecordsOperation.

## See Also

### Modifying Records

- [modifyRecords(saving:deleting:savePolicy:atomically:completionHandler:)](cloudkit/ckdatabase/modifyrecords(saving:deleting:savepolicy:atomically:completionhandler:).md)
- [CKModifyRecordsOperation.RecordSavePolicy](cloudkit/ckmodifyrecordsoperation/recordsavepolicy.md)
- [save(_:completionHandler:)](cloudkit/ckdatabase/save(_:completionhandler:)-3tatz.md)
- [delete(withRecordID:completionHandler:)](cloudkit/ckdatabase/delete(withrecordid:completionhandler:).md)
