CloudKit: Query all extended user records

Hi, I'm planning to give the user an option to design its own selection color for a kinda calendar app.

(Internal CarSharing Planner, to be more precise.)


My idea was to extend the public 'Users' record type by a 'PreferredColor' value, which contains the RGB String representation of that given color.

This works great for the currently logged in user since I'm able to directly fetch the record like so:

var container = CloudKit.getDefaultContainer();
var publicDB = container.publicCloudDatabase;

return publicDB.fetchRecord( { recordName: currentUser.id, zoneID: '_defaultZone' } ) .then(function(response) { /* ... */ }

(CloudKit JS)


But as soon as I try to gather the 'PreferredColor' fields of all users I'm stuck.

Directly querying the 'Users' record leads to an error.

[Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (query, line 0)


That is great for security reasons and all I need to properly assign the user and the color is the recordName and the 'PreferredColor' field of every 'Users' record.

Is it possible to filter the desired return fields in a query?


Or is the whole attempt bad and I should store this UserID:PreferredColor assignment in an own record type?

See the docs on CKQueries.

You cannot query for user records and executing a query where the record type is set to CKRecordTypeUserRecord results in an error. You must fetch user records directly using their ID.

So CloudKit doesn't let you query User records which is dissapointing given they do let you add custom fields, so it's like they are setting you up for a giant failure. Hopefully this feature will be added WWDC 2016! Cloud database security is pretty tough so I appreciate the time it'll take to solve whatever problems they are having with this feature.

CloudKit: Query all extended user records
 
 
Q