Search code examples
javascriptember.jsember-data

How to reload an async with links hasMany relationship?


Lets say we have

Post = DS.Model.extend({
  comments: DS.hasMany({async: true})
})

Comment = DS.Model.extend({
  post: DS.belongsTo()
})

and I have to use the links feature because otherwise I get a 414 error due to too much comments on a post.

Since this commit https://github.com/emberjs/data/commit/4d717bff53f8c93bedbe74e7965a4f439882e259

It seems like it's impossible to trigger a reload of the post.get('comments'), ie sending a GET request on for example post/42/comments.

Is there any solution for that ?


Solution

  • Thanks to @igorT, this is implemented. https://github.com/emberjs/data/pull/2297

    Now the ManyArray has a reload() method, which you can even call if the relation has not been loaded yet.

    You can see some use cases by reading the tests