How do I query for nil values with CloudKit.js?

前端 未结 1 1595
生来不讨喜
生来不讨喜 2021-01-25 02:20

Using CloudKit.js, how do I construct a query that matches items where a field is nil? Every permutation I\'ve tried fails - either it\'s clearly matching on a string value (i.e

相关标签:
1条回答
  • 2021-01-25 03:03

    I don't think there is any option to query for nil values in CloudKit. Also not from native code. I have tried a lot of predicates, but non seems to work.

    You do have to be aware that CloudKit is a key-value store. When a value is nil, then the key won't be there in the record. There is no option to query for non existing keys.

    The closest I have come to a good solution was with a predicate with the format "NOT myField => ''" sorry, don't know the format for .js

    In the CloudKit CKQuery documentation there is nothing mentioned about nil fields.

    In the documentation for NSPredicates there are sample's for nil values.

    But it was already clear that CloudKit has implemented only a subset of the possibilities of NSPredicate (see CKQuery class reference)

    I think the best way to handle this is by not using/depending on nil values. If you do need to check some nil status, then instead you could add an extra field that would represent that status.

    0 讨论(0)
提交回复
热议问题