realm cocoa: is it possible to do queries on links

若如初见. 提交于 2019-12-24 14:21:51

问题


On the following object model:

// Dog model
class Dog: RLMObject {
    var name = ""
    var owner = Person()
}

// Person model
class Person: RLMObject {
    name = ""
    birthdate = NSDate(timeIntervalSince1970: 1)
    dogs = RLMArray(objectClassName: Dog.className())
}

is it possible to query for all person's who have a dog whose name starts with 'B' i.e. something like

Person.objectsWhere("ANY dogs.name name BEGINSWITH 'B'")

I have tried it, doesn't seem to work on realm-cocoa 0.89.1


回答1:


This should work, you have an extra name in the predicate statement, it should read like this:

Person.objectsWhere("ANY dogs.name BEGINSWITH 'B'")


来源:https://stackoverflow.com/questions/27724664/realm-cocoa-is-it-possible-to-do-queries-on-links

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!