0
votes

Let's say I have two CloudKit record types:

  • Company

    • name (string)
    • etc...
  • Employee

    • first name (string)
    • etc...
    • company (reference to Company)

In my app if I have an array Companies, is there a way to query CloudKit for all Employees whose company is in this array with a single query? Obviously I could go through the companies array and query one by one, but if this array is large then that's going to be a lot slower.

The docs say that you can reference an array in a CKQuery predicate, but doesn't say how.

1

1 Answers

2
votes

Yes you can use the predicate

NSPredicate(“%k IN %@“, company, arrayofcompaniesReference)

  • company is the key in employee record type
  • arrayOfCompaniesReference is the array of reference of companies you have.