-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dontsave hasmany #61
Dontsave hasmany #61
Conversation
@nolanlawson This is needed to support async relations in ember-data. Like to merge pouchdb-community/ember-pouch#159 to get there. |
@broerse Don't know if I would call it suport for async relations. Those are already possible. But not without saving the ids on the hasmany side, which in my opinion has introduced multiple problems. |
@broerse I've made you a contributor on this project and a publisher on the npm package. Unfortunately I don't have much time for relational-pouch or ember-pouch anymore. Sorry for the delay! |
@nolanlawson Thanks! Will try to release a new version today. |
@jlami Perhaps reference this new functionality in the readme before I publish a new version? Can you write a PR for this? |
@broerse Sure, I'll try to do it this weekend. But no promises ;) |
I added an extra option
queryInverse
to request the hasMany relation to use a query instead of saving the ids.I added this option so pouch would not need to save the hasMany side. This makes the relation not dependent on the parent document. In my eyes this is more in line with the way couch/pouch wants to edit documents. See my ember-pouch PR for further information.
I also added 2 new api entry calls.
findHasMany
, to be able to use this query setup from outside of relational-pouch. AndparseRelDoc
to be able to parse relation pouch documents when getting data from outside of relational-pouch (e.g. from db.find/pouchdb-find). This makes sure all the related documents are being sideloaded if requested by the schema.findHasMany
also uses this new parse path, as does the allDocs that_find
uses. This way only one code path is required for parsing relational-pouch data.It might be good to setup the find indexes in this module, instead of in ember-pouch. But ember-pouch does not always give relational-pouch the information on hasMany relations that are async and queried, as those don't need any action from the relational-pouch side. Those still need indexes, so for now I do this in ember-pouch.