Type Function Object CloudKitRecord Return value none Revision Release 2024.3703 Keywords iCloud, sync, storage, CloudKit, CloudKitRecord, set See also CloudKitRecord CloudKitRecord:get() iCloud.recordCreate() iCloud.*
Sets the value of a specific field in a record.
CloudKitRecord:set( field, value )
String. The field name for which to set the value.
Table, String, or Number. Value to store in the record. This value is typically passed as a table containing the required type
key, along with the associated keys noted in Record Values below. However, strings and numbers can be passed directly as a convenience method.
When passed as a table, the associated type
value. In each case, all "reference"
type instance (see notes below). Here is the outline for each represented type:
Type | Keys | Lua Type(s) |
---|---|---|
"string" |
string |
string |
"number" |
number |
number |
"data" |
data |
string |
"location" |
latitude , longitude |
numbers |
"date" |
time |
number |
"reference" |
recordName , zoneName , zoneOwner , action |
strings |
"asset" |
path |
string |
"array" |
array |
table |
Value types of "reference"
require the recordName
key, but the other keys are optional. If set to a unique identifier, this recordName
value can be used to relate the record to a parent record with the same identifier. In addition, if the action
key’s value is "deleteSelf"
, the record becomes a child of the parent and it will be deleted if/when the parent record is deleted. See the usage example below for details.
Value types of "array"
require the array
key and its value should be an indexed
local function fetchResults( event ) if event.record then -- String and number values can be passed directly (convenience method) event.record:set( "company", "Corona Labs" ) event.record:set( "amount", 1 ) -- Other value types must be passed as a table event.record:set( "where", { type="location", latitude=37.453139, longitude=122.113451 } ) else print( "Record not fetched!" ) end end iCloud.recordFetch( { recordName = "Corona Labs 1", onComplete = fetchResults } )