createOrUpdate
Creates or updates one or more records depending on the information provided.
Declaration
CloudKit.RecordsBatchBuilder createOrUpdate(
CloudKit.Record|CloudKit.Record[] records,
optional Object options
);Parameters
- records:
A Cloudkit.record dictionary representing the record to create or update, if you are updating a single record. If you are updating multiple records, this parameter is an array of Cloudkit.record dictionaries representing the records to create or update. Only the values of the fields in the dictionaries are set.
- options:
A dictionary containing options for this operation. This parameter contains a single
desiredKeyskey that is an array of field names (Stringvalues). Only the fields specified in the array are set.
Return Value
The object that received this method call.
Discussion
This is a convenience method for adding create and update operations rather than adding them separately using the create and update methods. Depending on the information in the record, this method determines whether the record should be created or updated.
The type of operation depends on the values of the recordName and recordChangeTag keys in the CloudKit.Record dictionaries.
To create a record with a server-generated record name, set the
recordNameandrecordChangeTagkeys tonull.To create a record with a specified record name, set the
recordNamekey to the record name and setrecordChangeTagtonull.To update an existing record, set the
recordNameandrecordChangeTagkeys to non-nullvalues.
An error occurs if the recordName key is null and the recordChangeTag key is non-null. Retain the record name of records you previously fetched, and include it when updating a record.