Comments (6)
@jetamartin Yes it is automatic when you use queryInverse
but you need to add pouchdb-find
to your project. I understand that it is confusing but you need indexes for pouchdb-find
. See https://github.com/pouchdb-community/ember-pouch/blob/master/addon/adapters/pouch.js#L209 where we create them. It works without creating the indexes but it is much slower. See also mango-queries Perhaps we should try to add a working example and improve the readme. The ember-pouch addon maybe interesting to look at.
from relational-pouch.
@broerse Thanks for the reply to my first question. BTW, I do have pouchdb-find installed in my project and it didn't seem to be automatic in my code. Hence my questions. Maybe I'm doing something wrong? I'm assuming the code you referenced in your response was intended to show that index is automatically created?
Any thoughts or comments about my other questions?
From my perspective more examples are ABSOLUTELY needed given the vagueness and ambiguity of the documentation. As a user I have lots of feedback on the documentation. It needs a LOT of work.
from relational-pouch.
@jetamartin the second question comes from the confusing "By default relational-pouch will store the child ids of an Many-to-one relationship as a property on the many side (the parent)." So the use of relational-pouch without queryInverse
is considered the default. In that case using relational-pouch will need you to store the child ids on the many side as described in the doc. If you use queryInverse
you do not. We are not native English speakers so please make a PR to improve this sentence.
from relational-pouch.
@broerse,
Thanks for the reply. Thanks for letting me know that English is really a second language of the developers/documenters. The root of my confusion on "one-to-many" arose from two issues:
-
As I noted my reply above I'm not seeing the child ids being automatically added as a property on the many side as you say. I'm assuming I must be doing something wrong in my code.
-
The example provided in the documentation for the "one-to-many" relationship shows the the child ids (books) being added manually (e.g., books: [1, 2]) via the db.rel.save(). Why would the only example provided not show the "default" behavior? That makes no sense to me and created some of the confusion. I would suggest that you change the example to show the 'default' behavior and add a note at the bottom of the example stating that the user could manually add the childIDs if they'd like.
The other points of confusion that I noted arise because in numerous places the language in the documentation creates ambiguity/vagueness on what is "automatic" system behavior (i.e., requires no explicit user action) vs what actions must be taken explicitly taken by the user. The reader is left with the question...do I need to do something in addition to what is being shown in the example? or is the documentation merely describing how it uses the parameters the user provides? Explaining what/how the system accomplishes something or how it makes use of the parameters provided by the user is great but the documentation needs to be clear on when the user needs to do something.
Another general point I'd like to see addressed in the documentation is the relationship of relational-pouch to pouchdb. My understanding is that relational-pouch sits on top of pouchdb but can a user call pouchdb API methods directly when they have relational-pouch installed. Are the relational-pouch APIs meant to provide a "complete set of API's" needed or is it expected and allowed for the user to make use of pouchdb API's to accomplish certain "tasks".
An accompanying diagram showing the relationship of relational-pouch db would be useful along with a description that denotes pouchdb API's that can and can't be used with relational-pouch. (I realize some can't be used directly because of the "compound" key required for relational-pouch). As I stated I don't know whether relational-pouch is intended to provide an all encompassing set of APIs or its intended to provide a subset of APIs as portrayed by the picture.
| User App |
|---------------|------------------|--------|
--------------- v -------- |
| relational-pouch APIs | |
|| |
------------ |--------------------- |--------
| v pouchdb APIs v |
(Note: the formatting of the above diagram seems to be lost unless you are in edit mode. :(
Perhaps the most important thing you could do to clarify the documentation is to create documentation/video that shows how someone would use the relational-pouch apis to build a simple application. This would serve to clarify many of the ambiguities in the documentation and it would boost usage of relational-pouch. The PouchDB github site shows an example app via documentation and via a video (narrated by Nolan Lawson). Perhaps you could have Nolan create a video for you guys?
That's all for now.
**** Hoping someone can address my other outstanding issue re: not being able to "perform" relational-pouchdb operations (e.g., db.rel.save()) from the Chrome console. If I can't do that then it's a showstopper for me. I'll have to abandon this plugin.
from relational-pouch.
@jetamartin I try to explain that if you use queryInverse
with a model like this you don't store the hasmany posts
array. See the record in CouchDB.
I keep an example up-to-date that uses relational-pouch. Perhaps try that. https://github.com/broerse/ember-cli-blog or take a look at the big https://github.com/HospitalRun/hospitalrun-frontend
from relational-pouch.
I am so glad to see this post made by @jetamartin , i thought i was the only one facing this as well. I am having a difficult time implementing db.rel.findHasMany and from the documentation i can't really tell if i am on the right path or not.
from relational-pouch.
Related Issues (20)
- Dead link in documentation HOT 1
- Heelp!!!! new post not adding to authors HOT 2
- Depreciate IE8 support HOT 1
- Delete all schema docs.
- Is db.rel.find() have an option for paging? HOT 12
- How to use 'pouchdb-validation' and 'relational-pouch'?
- How does the sync performance of this compare to vanilla pouchdb?
- Handling error while saving Relational data
- Handling ECONNRESET HOT 4
- don't save hasMany/queryInverse with many-to-many HOT 2
- find and delete by id not working
- find action, slow performance HOT 2
- db.rel.findHasMany is not working HOT 3
- [help] CouchDb 3.0 - Partitioned Databases HOT 5
- Delete successful but data has not removed HOT 2
- How to return _conflicts attribute HOT 1
- how to get sort data? HOT 1
- why pouchdb.rel.find() works only with integer id? HOT 6
- React Native app crashes when try to import
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from relational-pouch.