John Scalo
John Scalo

Reputation: 3401

CloudKit query for reference in array

Let's say I have two CloudKit record types:

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.

Upvotes: 0

Views: 378

Answers (1)

Karan Khullar
Karan Khullar

Reputation: 21

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.

Upvotes: 2

Related Questions