Thanks, currently i had to change to use single property and looking forward this feature will be released.
Thanks. On Thursday, February 26, 2015 at 11:14:03 AM UTC+7, Jens Alfke wrote: > > New feature available on the iOS/Mac master branch, as described in issue # > 606 <https://github.com/couchbase/couchbase-lite-ios/issues/606>: > > 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: > > - The property value is *recomputed on every call*. > - These properties are *not KV-observable* (that would be great to add > later, but it would require something like a LiveQuery, and would have to > be carefully optimized to be scaleable.) > > 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 +*property*ItemClass 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 +*property*InverseRelation 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"; } > ... > > > -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/6b142b26-5d39-46bb-abf7-69a6756de63a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
