ember-indexeddb-adapter
ember-indexeddb-adapter copied to clipboard
async:true needed to load associations
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?
This was my experience also.
+1
+1
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.
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.