0
votes

I need to check which CKRecords in CloudKit container don't have parent record yet. How I can fetch only records that do not have parent yet? I've tried NSPredicate, but getting an error "Unknown field 'parent'".

enter image description here

1
What do you mean by "parent". Records only have relations to other records if you set them up yourself (with reference fields). If you want to find records without a reference field, that can be done with a predicate. - john elemans
Hi John. If we are talking about the same. CKRecord has 'parent' property (it can be set using setParent(:) method), in Dashboard I see that as 'reference'. Tell me please how to find records without a reference field using predicate as you said. - bodich
I'm still working on this, but for now I can tell you that the setParent will create a field in your record and set a reference to the parent. The field is called "parent", but because the field called "parent" does not appear in your schema, you cannot search on it. - john elemans
setParent does not create database field, it's just set a CKRecord object property. I know that I cannot search by it, that's the reason of my question actually. I wrote about "Unknown field 'parent'" in question from the beginning. - bodich

1 Answers

0
votes

You can’t achieve this with a simple query, but you can filter fetched records where Share property is nil.