Vuk Nikolić
Vuk Nikolić

Reputation: 97

Realm.io relationship queries

I'm using realm.io 0.90 with objective c. I'm able to save/edit/delete objects with their relationships without a problem.

Here is my database schema: class A that has an array of class B. And class B has an array of class C (A->B->C)

I need to query for all As with any B that have C.name = "something"

Any ideas how to do it?

Upvotes: 2

Views: 1216

Answers (1)

marius
marius

Reputation: 7806

You can use here the NSPredicate-based Query-API.

// Query using an NSPredicate object over multiple relations
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY bs.cs.name = %@",
                                                          @"something"];
RLMResults *asWithCsNamedSomething = [A objectsWithPredicate:predicate];

Upvotes: 6

Related Questions