Class

CloudKit.RecordsBatchBuilder

A CloudKit.RecordsBatchBuilder object encapsulates the results of changes to multiple records in a single database operation.

Declaration

interface CloudKit.RecordsBatchBuilder

Overview

It is more efficient to use this class to batch multiple record changes into a single operation than to use the individual record change methods in the CloudKit.Database class. Using this class is especially important if the record types contain Reference fields. CloudKit ensures that in a graph of related records, target records are saved before source records.

You should not create instances of this class directly. Instead use the newRecordsBatch method in the CloudKit.Database class to get a CloudKit.RecordsBatchBuilder object. Then use the create, replace, and delete methods in this class to build the batch operation. Use the commit method to execute the batch operation.

For convenience, most methods in this class that add operations return the CloudKit.RecordsBatchBuilder object so that you can chain method calls together; for example:

myDatabase.newRecordsBatch()
    .create(someRecord)
    .update(someOtherRecord)
    .delete(aThirdRecord)
    .commit()

For similar web service operations, read Modifying Records (records/modify) in CloudKit Web Services Reference.

Topics

Creating and Updating Records

create

Creates one or more records.

createOrUpdate

Creates or updates one or more records depending on the information provided.

update

Updates one or more existing records.

forceUpdate

Updates one or more existing records regardless of conflicts.

Replacing Records

replace

Replaces one or more records with the specified records.

forceReplace

Replaces one or more records with the specified records regardless of conflicts.

Deleting Records

delete

Deletes one or more records.

forceDelete

Deletes one or more records regardless of conflicts.

Executing Operations

commit

Executes the operations on the database that created this batch builder object.