如何使用链接重新加载异步有许多关系? [英] How to reload an async with links hasMany relationship?
问题描述
假设我们有
Post = DS.Model.extend({
comments: DS.hasMany({async: true})
})
Comment = DS.Model.extend({
post: DS.belongsTo()
})
而且我必须使用 links
功能,否则我会因帖子评论过多而收到 414 错误.
and I have to use the links
feature because otherwise I get a 414 error due to too much comments on a post.
自从这次提交https://github.com/emberjs/data/commit/4d717bff53f8c93bedbe74e7965a4f439882e259"/a>
Since this commit https://github.com/emberjs/data/commit/4d717bff53f8c93bedbe74e7965a4f439882e259
似乎不可能触发 post.get('comments') 的重新加载,即在例如 post/42/comments 上发送 GET 请求.
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.
有什么解决办法吗?
推荐答案
感谢@igorT,这已经实现了.https://github.com/emberjs/data/pull/2297
Thanks to @igorT, this is implemented. https://github.com/emberjs/data/pull/2297
现在 ManyArray 有一个 reload() 方法,如果关系尚未加载,您甚至可以调用该方法.
Now the ManyArray has a reload() method, which you can even call if the relation has not been loaded yet.
您可以通过阅读测试
这篇关于如何使用链接重新加载异步有许多关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!