Skip to content
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

Support request #1

Open
bwilk opened this issue Mar 31, 2016 · 6 comments
Open

Support request #1

bwilk opened this issue Mar 31, 2016 · 6 comments

Comments

@bwilk
Copy link

bwilk commented Mar 31, 2016

Hello,
schema-couch is a great library - does almost all I need for publishing API based on interrelated documents stored in couchdb. However I'm struggling to get "belongs_to" relationship working. As you suggested I started from the example and prepared several documents conforming to the sample schema.

Context:

Using following GET method request:
http://localhost:5984/schema_couch/_design/schema/_rewrite/quiz/id/c75915ae788a3f3a85fb8bbcc6001d49

I get the response:
{"_id":"c75915ae788a3f3a85fb8bbcc6001d49","_rev":"3-9b70e0f2e058f8c0b66a3d0130e5299c","data":{"question":"do you know couchdb?","choices":{"a":"yes","b":"no"},"answers":["yes","no"],"category":"miscellaneous","difficulty":5},"type":"quiz"}

So I have a proper quiz :). It seems to me that I also have proper submission for that question:
http://localhost:5984/schema_couch/_design/schema/_rewrite/submission/id/c75915ae788a3f3a85fb8bbcc6008472

Response:
{"_id":"c75915ae788a3f3a85fb8bbcc6008472","_rev":"1-4acf21962a9aa8a0b92941482ec0f0ee","type":"submission","data":{"question_id":"c75915ae788a3f3a85fb8bbcc6001d49","user_id":"wacek","answer":"yes"}}

I even get that submission when I list submissions of a certain quiz:
http://localhost:5984/schema_couch/_design/schema/_rewrite/quiz/id/c75915ae788a3f3a85fb8bbcc6001d49/has_many/submissions

Response:
{"total_rows":4,"offset":0,"rows":[ {"id":"c75915ae788a3f3a85fb8bbcc600bcf2","key":["c75915ae788a3f3a85fb8bbcc6001d49","submissions","no"],"value":null}, {"id":"c75915ae788a3f3a85fb8bbcc6008472","key":["c75915ae788a3f3a85fb8bbcc6001d49","submissions","yes"],"value":null} ]}

Issue

But when it comes to the "belongs_to" relationship things get much worse:
http://localhost:5984/schema_couch/_design/schema/_rewrite/submission/id/c75915ae788a3f3a85fb8bbcc6008472/belongs_to/quiz

Response:
{ "error": "not found", "ok": false }

The "quiz" relationship name is listed when I request for:
http://localhost:5984/schema_couch/_design/schema/_rewrite/submission/id/c75915ae788a3f3a85fb8bbcc6008472/belongs_to

Response
{ "rows": [ "quiz", "user" ] }

Question

Could you please explain what am I doing wrong?
Thank you in advance for your support

@ryanramage
Copy link
Owner

I will try and have a look at this on the weekend. I really like schema-couch, but I have neglected it for a bit. Glad you like it!

@bwilk
Copy link
Author

bwilk commented Apr 4, 2016

Thank you. Let me know if you find a solution

@kristianmandrup
Copy link
Contributor

Any resolution to this? I'd like to use it with cradle

@kristianmandrup
Copy link
Contributor

@bwilk I guess you have to debug from rewrites

The code could definitely use some refactoring...

@kristianmandrup
Copy link
Contributor

@bwilk You might want to work/experiment from this branch

@bwilk
Copy link
Author

bwilk commented Oct 24, 2016

@kristianmandrup thanks for the notification - I'm going to try this branch soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants