User123
User123

Reputation: 45

realm cocoa: is it possible to do queries on links

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

Upvotes: 1

Views: 303

Answers (1)

yoshyosh
yoshyosh

Reputation: 14086

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

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

Upvotes: 2

Related Questions