如何重新加载异步与链接有很多关系? [英] How to reload an async with links hasMany relationship?

查看:83
本文介绍了如何重新加载异步与链接有很多关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我们有

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

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

,我必须使用链接功能,否则我得到由于对帖子的评论太多,导致414错误。



由于此提交 https://github.com/emberjs/data/commit/4d717bff53f8c93bedbe74e7965a4f439882e259



似乎无法触发重新加载post.get('comments'),即发送GET请求例如post / 42 / comments。



有没有解决方案? p>

解决方案

感谢@igorT,这是实现的。 https://github.com/emberjs/data/pull/2297



现在,ManyArray有一个reload()方法,如果关系尚未加载,您甚至可以调用。



您可以通过阅读测试


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 ?

解决方案

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

这篇关于如何重新加载异步与链接有很多关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆