iCloud.recordQuery()

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

Overview

Retrieves existing records based on a defined query and passes the results to the onComplete listener function as iCloudRecordEvent.recordArray.

Gotchas

You must pass a predicate to filter records. Predicates are formed according to Apple's documentation.

Syntax

iCloud.recordQuery( params )
params (required)

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

Parameter Reference

Valid keys for the params table include:

Example

local json = require( "json" )

function queryResults( event )

    if event.recordArray then
        print( "Total records retrieved: ", #event.recordArray )
        if #event.recordArray > 0 then
            for r = 1,#event.recordArray do
                print( "----------" )
                print( json.prettify( event.recordArray[r]:table() ) )
                print( "----------" )
            end
        end
    else
        print( "No records found!" )
    end
end

iCloud.recordQuery(
    {
        type = "people",
        query = "TRUEPREDICATE",
        onComplete = queryResults
    }
)