Let's say I have a model (subclass of CBLModel) with many children.Is this the suggested way of setting up the relationship?
Is there a better way to do it so when the parent gets deleted, the children get deleted too?
--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/mVIJQ0s_pS4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/be76cf92-f59a-4638-907d-caa18610554f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Interesting.
Yes ! We have a lot of fun with CouchBaseLite !
And we use the core data tool to design our models. We take advantage of the 'User Info' in the data model inspector to precise our specific information. For example, we use it to specify whether a model is a nested or a root.
Generated classes inherit from CBLModel for root models, and from our own root class for nested models.
Our end-user classes inherit from generated classes so it is easy to regenerate code when modeling changes.
And of course, we use separate parent and child models because we want to be able to reuse child models.
For example, an address model is nested in many different models. Even if we need to access to parent specific features in a children, it is not an issue: we just ask the parent to implement a protocol.
A big advantage of our tool is to generate code for nested (To One or ToMany, handling json serialization), attachments (for example, images), validation, labels, and other issues.
We did the same thing on the graphic user interface, we reuse the 'detail view' so it is fully object oriented. For example, in a coordinate model, there are nested emails, nested urls, nested phone numbers and a nested address. In the detail of coordinate, we just put a CustomView for each nested giving it the name of relation.
After, when we load the detail of coordinate, it loads automatically the master/details of the nested ToMany relation or the detail of the nested ToOne relation. We handle issues such as adjusting priority levels for constraints!.
So we can play to 'lego' buidling our end-user application.
For now, our application is under Mac OS, but we aim to synchronize with applications on iPad or mobile taking full advantage of CouchBaseLite and CouchDB/CouchBase technologies.
Laurent
I think it is possible to share this code with the community !