kurko / ember-indexeddb-adapter

Ember Data IndexedDB Adapter
MIT License
43 stars 16 forks source link

async:true needed to load associations #13

Open mattmarcum opened 10 years ago

mattmarcum commented 10 years ago

I tried loading a route without {async:true} on the hasMany relation of the route's model...but I got the "uncaught Error: Assertion Failed: You looked up the 'model' relationship on 'model'..." error. I added the {async:true} option back to the hasMany relationship and the route loaded fine. Maybe the readme needs to be updated?

rsutphin commented 10 years ago

This was my experience also.

cheneveld commented 10 years ago

+1

dpfens commented 10 years ago

+1

rsutphin commented 9 years ago

I noticed today that the integration tests for the library don't use async: true on their hasMany's and work fine.

I played around with it in my app a bit and found that I could only omit { async: true } if I ensured that the associated records were already cached in the store (e.g., by calling store.find('theAssociatedModel') before store.find('thePrimaryModel', 'some-id')). I tried simulating the opposite situation in the tests (via store.unloadAll('theAssociatedModel')) and still could not reproduce the error.

rsutphin commented 9 years ago

I figured out the difference between the part of my app I was using to experiment and the tests. I was using find all in my app — store.find('the-primary-model'). The tests find a specific record: store.find('the-primary-model', 'some-id'). It appears that the adapter does recursive synchronous relationship loading only for the single record case.