[英]How do you limit results from a findAll in ember.js?
My api takes query parameters such as "page". 我的api接受查询参数,例如“page”。 This is to limit the number items sent over.
这是为了限制发送的项目数量。 I realize you can filter these with ember once they've already been retrieved, but I want this app to scale.
我知道你可以在它们已被检索后用ember过滤这些,但我希望这个应用程序可以扩展。 This means I can't be receiving large amounts of data over the wire like findAll already does.
这意味着我无法像findAll那样通过网络接收大量数据。 How would I go about doing this in ember?
我将如何在余烬中做到这一点? Where should I put my custom ajax?
我应该在哪里放置我的自定义ajax? I still would like to use most of the features ember has like the ability to watch my models.
我仍然想使用ember所具有的大部分功能来观看我的模型。
This sounds like you want pagination support, but lamentably this feature is still not implemented in ember core. 这听起来像你想要分页支持,但可悲的是这个功能仍未在ember核心中实现。 However some folks have already created pagination support to work with ember, one very good example is from Toran Billups, have a look here: https://github.com/toranb/ember-pagination-example .
然而,有些人已经为使用ember创建了分页支持,一个很好的例子来自Toran Billups,请看一下: https : //github.com/toranb/ember-pagination-example 。 Have also a look here for a good answer explaining it's implementation: Ember pagination full example
还可以在这里找一个解释它的实现的好答案: Ember分页完整的例子
Hope it helps. 希望能帮助到你。
Perhaps I misunderstand your question, but you can use App.Model.findQuery
and pass it query string parameters, which will be sent to your server. 也许我误解了你的问题,但你可以使用
App.Model.findQuery
并传递它的查询字符串参数,这些参数将被发送到你的服务器。
For example: App.Model.findQuery({page: 5, color: 'blue'})
. 例如:
App.Model.findQuery({page: 5, color: 'blue'})
。 Of course it's up to your API to implement the response to the query params. 当然,由您的API来实现对查询参数的响应。
See also: what's the difference between find, findAll and findQuery in ember-data findQuery source 另请参阅: ember-data findQuery源中 find,findAll和findQuery之间的区别是什么
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.