iCloud.recordFetchMultiple()

Type Function
Return value none
Revision 2017.3060
Keywords iCloud, sync, storage, CloudKit, recordFetchMultiple
See also iCloud.recordFetch()
iCloud.recordQuery()
iCloudRecordEvent
iCloud.*

Overview

Retrieves multiple records. Per-record results are passed to the onRecord listener function and final results are passed to the onComplete listener function, both as an iCloudRecordEvent.

Syntax

iCloud.recordFetchMultiple( params )
params (required)

Table. Table containing method-specific parameters — see the next section for details.

Parameter Reference

Valid keys for the params table include:

If zones are not being used, simply pass this value as a list of record identifiers (strings):

recordNameArray = { "r1", "r2", "r3" }

If zones are being used, pass this value as an array of tables containing record identifiers and zone details:

recordNameArray = {
    { recordName="r1", zoneName="z1", zoneOwner="o1" },
    { recordName="r2", zoneName="z2", zoneOwner="o2" }
}

Example

-- Listener function to handle per-record events
local function recordFetched( event )

    print( event.record )      -- Specific fetched record
    print( event.isError )     -- Indicates whether an error occurred
    print( event.recordName )  -- If an error occurred, identifies the record involved
    print( event.error )       -- Description of the error which occurred, if any
end

-- Listener function to handle the overall fetch request
local function fetchResults( event )

    print( event.recordArray )  -- Array of successfully retrieved records
    print( event.isError )      -- Indicates whether an error occurred
    print( event.error )        -- Description of the error which occurred, if any
end

iCloud.recordFetchMultiple(
    {
        recordNameArray = { "r1", "r2", "r3" },
        onRecord = recordFetched,
        onComplete = fetchResults
    }
)