根据 RLMArray 属性 的大小查询所有对象的领域?
Query Realm for all objects based on the size of a RLMArray property?
我们正在尝试编写一个 Realm 查询来检索 RLMArray 属性 大小为特定数字的所有对象。领域模型如下所示:
class Foo: RLMObject {
dynamic var people = RLMArray(objectClassName: User.className())
}
我们已经尝试过但没有成功的查询的多次迭代如下:
// 'Invalid predicate expressions', reason: 'Predicate expressions must compare a keypath and another keypath or a constant value'
let results = Foo.objectsWhere("people[SIZE] = %d", 2)
// 'Invalid predicate', reason: 'RLMArray predicates must contain the ANY modifier'
let results = Foo.objectsWhere("people.@count = %d", 2)
// 'Invalid column name', reason: 'Column name @count not found in table'
let results = Foo.objectsWhere("ANY people.@count = %d", 2)
我们查看了多个示例、Apple 关于 NSPredicate 的文档和其他 SO 答案,但我们似乎无法找到答案。我们如何根据 RLMArray 的大小查询所有对象 属性?
那是 limitation of Realm until the release of version 0.96. Since then Keypath Collection Queries 受支持。
我们正在尝试编写一个 Realm 查询来检索 RLMArray 属性 大小为特定数字的所有对象。领域模型如下所示:
class Foo: RLMObject {
dynamic var people = RLMArray(objectClassName: User.className())
}
我们已经尝试过但没有成功的查询的多次迭代如下:
// 'Invalid predicate expressions', reason: 'Predicate expressions must compare a keypath and another keypath or a constant value'
let results = Foo.objectsWhere("people[SIZE] = %d", 2)
// 'Invalid predicate', reason: 'RLMArray predicates must contain the ANY modifier'
let results = Foo.objectsWhere("people.@count = %d", 2)
// 'Invalid column name', reason: 'Column name @count not found in table'
let results = Foo.objectsWhere("ANY people.@count = %d", 2)
我们查看了多个示例、Apple 关于 NSPredicate 的文档和其他 SO 答案,但我们似乎无法找到答案。我们如何根据 RLMArray 的大小查询所有对象 属性?
那是 limitation of Realm until the release of version 0.96. Since then Keypath Collection Queries 受支持。