Cloudkit Queries and Predicates

Can someone tell me please is it possible to create a query for cloudkit which will perform an operation on the records within cloudkit and just return a result based on those records.


For example,

If there were 100 records in cloudkit, and one of the fields was age, can a query be constructed to look at all records and just return the average age, rather than having to download every record and then perform the calculation.


Thanks.

Accepted Reply

> create a query for cloudkit which will perform an operation


Given what you mean by "operation", no, you must download the record (*) and do the calculation yourself.



* You can download only the fields you want with:

https://developer.apple.com/documentation/cloudkit/ckqueryoperation/1515268-desiredkeys?language=objc

Replies

> create a query for cloudkit which will perform an operation


Given what you mean by "operation", no, you must download the record (*) and do the calculation yourself.



* You can download only the fields you want with:

https://developer.apple.com/documentation/cloudkit/ckqueryoperation/1515268-desiredkeys?language=objc

Thanks for your reply.


(Yes I was meaning a maths operation, not a query operation.)


How many returned records do you think is acceptable?

I am working on a project where the returned records could number in the 10s of thousands!

I probably need to return five fields per record. (mixture of strings and numbers)


I have never had to return this many results before from cloudkit and don't know if this is acceptable, or what type of delays I can expect?


Thanks.

It may not be that bad. You use a token and recursively call the query with the token.