Kingdom and Property Indexes

CONTEXT

The kingdom does not support property indexes of relations (objects). https://realm.io/docs/objc/latest/#indexed-properties If you try, this will throw an error.

We have a situation where we need to request model relationships and another property.

Usually you do this by having the coverage index through (foreign_id, property), but this is not possible in Realm (yet?)

for instance

@interface Book : RLMObject
@property NSNumber<RLMInt> * page;
@end

@interface Page : RLMObject
@property Book * book;
@property NSNumber<RLMInt> * line;
@end

[Page objectsInRealm:realm where:@"book.uuid = %@ AND page.line = %@", uuid, @1];

Question

What is the best way to tune indexes so that an optimized query is optimal? Already indexed relationship? Or am I creating another property on the page called book_uuid and indexing on it?

Greetings

+4
source share
1 answer

Realm , .

, , , Book ( ), , :

@interface Page : RLMObject
@property NSInteger line;
@end

RLM_ARRAY_TYPE(Page)

@interface Book : RLMObject
@property RLMArray<Page *><Page> *pages;
@end

Book *book = [[Book allObjects] firstObject];
Page *page = [[book.pages objectsWhere:@"line = %@", @1] firstObject];

line , . , , , .

+1

Source: https://habr.com/ru/post/1660078/


All Articles