Added CBLModel support for computed inverse-relation properties (a typical ORM feature, also found in Core Data.)
For example, if the Album class has a relation @property Artist* artist (i.e. the JSON property value is the docID of a document corresponding to an Artist model), then it should be possible to define a property on Artist like @property (readonly) NSArray* albums, whose value is an array of the Albumobjects whose artist property points to the receiver.
Behind the scenes, there's no JSON property backing this. Its value is computed on demand by querying a view that indexes the artist property of every album document. (If this turns out to be too slow we can cache the value until the view index changes.)
Caveats:
To define a property like this, you have to do three things:
1. Define the [dynamic] property itself, with type NSArray*.
2. Implement a class method +propertyItemClass that returns the class that has the inverse relation, i.e. the class of the items in the array to be returned.
3. Implement a class method +propertyInverseRelation that returns a string naming the relation property in the other class that should be queried.
In the example:
@interface Artist
@property (readonly) NSArray* albums;
...
@implementation Artist
...
@dynamic albums;
+ (Class) albumsItemClass { return [Album class]; }
+ (NSString*) albumsInverseRelation { return @"artist"; }
...On Feb 27, 2015, at 9:46 AM, Christoph Berlin <hoptoawe...@gmail.com> wrote:Hi Jens, very nice. Quick question: is or will this feature be supported on the Sync Gateway to allowing us to determine channel access rules?