-
Notifications
You must be signed in to change notification settings - Fork 3
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
Comments
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! |
Thank you. Let me know if you find a solution |
Any resolution to this? I'd like to use it with cradle |
@bwilk You might want to work/experiment from this branch |
@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
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
The text was updated successfully, but these errors were encountered: