Skip to content
This repository has been archived by the owner on Aug 26, 2019. It is now read-only.

Cannot get minimal example running #21

Closed
avanc opened this issue Jan 5, 2013 · 6 comments
Closed

Cannot get minimal example running #21

avanc opened this issue Jan 5, 2013 · 6 comments

Comments

@avanc
Copy link

avanc commented Jan 5, 2013

I tried to get a minimal example running (besides, how to add attachments):
https://gist.github.com/4462391

However, Firebug reports the following error:

TypeError: hash is undefined
return hash._id || hash.id;

This is line 22 in couchdb_adapter.js.

@pangratz
Copy link
Owner

pangratz commented Jan 5, 2013

I guess there is a race condition: the findQuery is executed too soon. Have you tried invoking findQuery when there is already a document in the database? Something like this: https://gist.github.com/4462422#file-minimal-couchdb_example-js-L50-L56

Also, what does the response look like when calling the view?

@avanc
Copy link
Author

avanc commented Jan 5, 2013

With these changes, I get no error. However, no output is shown on the site. In addition, Firebug only shows me the Get-Request for the "find" and a Post-Request for storing the new document. It seems that the findQuery is not executed.

Aditionally, the database already contains some documents, so findQuery should find anything. This the the output of the view in my browser:

{"total_rows":6,"offset":0,"rows":[
    {"id":"72674863c864a2dde83ffa535a007e4c","key":"ToDo","value":{"_id":"72674863c864a2dde83ffa535a007e4c","_rev":"1-16b76f5d6c34e884551bfe600f26a316","type":"ToDo","title":"New ToDo","content":"Some Details","creator":"Me","created_at":"2013-01-05","done":"false","ember_type":"(subclass of DS.Model)"}},
    {"id":"72674863c864a2dde83ffa535a008c6c","key":"ToDo","value":{"_id":"72674863c864a2dde83ffa535a008c6c","_rev":"1-16b76f5d6c34e884551bfe600f26a316","type":"ToDo","title":"New ToDo","content":"Some Details","creator":"Me","created_at":"2013-01-05","done":"false","ember_type":"(subclass of DS.Model)"}},
    {"id":"72674863c864a2dde83ffa535a009af9","key":"ToDo","value":{"_id":"72674863c864a2dde83ffa535a009af9","_rev":"1-16b76f5d6c34e884551bfe600f26a316","type":"ToDo","title":"New ToDo","content":"Some Details","creator":"Me","created_at":"2013-01-05","done":"false","ember_type":"(subclass of DS.Model)"}},
    {"id":"72674863c864a2dde83ffa535a009f95","key":"ToDo","value":{"_id":"72674863c864a2dde83ffa535a009f95","_rev":"1-16b76f5d6c34e884551bfe600f26a316","type":"ToDo","title":"New ToDo","content":"Some Details","creator":"Me","created_at":"2013-01-05","done":"false","ember_type":"(subclass of DS.Model)"}},
    {"id":"72674863c864a2dde83ffa535a00a97b","key":"ToDo","value":{"_id":"72674863c864a2dde83ffa535a00a97b","_rev":"1-16b76f5d6c34e884551bfe600f26a316","type":"ToDo","title":"New ToDo","content":"Some Details","creator":"Me","created_at":"2013-01-05","done":"false","ember_type":"(subclass of DS.Model)"}},
    {"id":"72674863c864a2dde83ffa535a00ac0a","key":"ToDo","value":{"_id":"72674863c864a2dde83ffa535a00ac0a","_rev":"1-16b76f5d6c34e884551bfe600f26a316","type":"ToDo","title":"New ToDo","content":"Some Details","creator":"Me","created_at":"2013-01-05","done":"false","ember_type":"(subclass of DS.Model)"}}
]}

@pangratz
Copy link
Owner

pangratz commented Jan 5, 2013

Ok, so the thing is that the response of a findQuery expects you to have include_docs set to true (see updated gist https://gist.github.com/4462422#file-minimal-couchdb_example-js-L51-L57). Does this make you example work?

That said, the next thing that I will work on is documentation, see #13.

@pangratz
Copy link
Owner

pangratz commented Jan 5, 2013

Another note: your ToDo model is not within the App namespace. That's why ember_type is "(subclass of DS.Model)" and not "App.ToDo" like it should be ...

@avanc
Copy link
Author

avanc commented Jan 5, 2013

You made my day!
With include_docs it works. Thanks for the very quick help.

@pangratz
Copy link
Owner

pangratz commented Jan 5, 2013

Nice, glad it works now!

I hope I can improve the documentation asap. Thanks for testing 😉

@pangratz pangratz closed this as completed Jan 5, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants