ember-localstorage-adapter
ember-localstorage-adapter copied to clipboard
Does not work with nested relatiosnhips
I am working on a custom adapter were the storage is a plain file, and to start with, I have borrowed some code from this adapter, which apparently is based on the indexed-db adapter. So far things work nice if i have simple relationships, lets say root item which has a has-many relationship and its child-items do NOT have its own has-many relationship. If they do have, things don't work anymore, as soon as I try to load those sub-items. I am gonna investigate what exactly will happen and report a solution if I find one. On the other, if you are aware of this issues, let me know how you think it can be solved
I suppose it's because {async: false}. Ember Data itself is full of bugs with async: true last time I checked. So, what I did here was load all dependencies that are 1 level deeper (resource hasMany resources). I believe you can iterate further in that recursive function, loading deeper levels.
Does that make sense? I believe Ember Data should be smart enough to handle both async or not relationships, but we're not at that point yet.
kurko, yes that makes sense. And I realised that you are loading just one level deeper (but got confused what happened if go even deeper, adpapter.findMany gets called, as I would expect it to happen in in async mode, but results in an error "cannot call 'resolve' of undefined". So how do I force to go one level deeper ? A counter instead of your recursive flag ?
Yep, that's how I'd do it, with a counter.
--Alexandre
On Sun, Mar 2, 2014 at 4:51 PM, Roberto Saccon [email protected]:
kurko, yes that makes sense. And I realised that you are actually loading just one level deeper (but got confused what happened to go even deeper, adpapter.findMany gets called, as I would expect it to happen in in async mode, but results in an error "cannot call 'resolve' of undefined". So how do I force to go one level deeper ? A counter instead of your recursive flag ?
Reply to this email directly or view it on GitHubhttps://github.com/rpflorence/ember-localstorage-adapter/issues/44#issuecomment-36464370 .