简体   繁体   English

你如何限制ember.js中findAll的结果?

[英]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.

相关问题 如何为ember.js创建自定义适配器? - How do you create a custom adapter for ember.js? 您如何断言Ember.js中使用了运行循环? - How do you assert a run loop was used in Ember.js? 如何在Handlebars / Ember.js中插入动态{{property}}? - How do you interpolate a dynamic {{property}} in Handlebars / Ember.js? 如何在Ember.js中创建计算属性以查看单个Ember Data属性是否为脏? - How do you create a computed property in Ember.js to see if a single Ember Data attribute is dirty? 如何在 Ember.js 中执行顺序 for 循环? - How to do a sequential for loop in Ember.js? Ember.js ember-data findAll远程服务器上的对象 - Ember.js ember-data findAll objects on the remote server 您如何在Ember.js中的javascript中复制诸如function(){…} .property()之类的内容? - How do you replicate something like function(){ … }.property() in javascript like in Ember.js? 如何使用视图中的复选框过滤Ember.js中ArrayController的内容集合? - How do you filter the content collection of an ArrayController in Ember.js using a checkbox in a view? 在Ember.js中,如何使用super()遍历对象继承树? - In Ember.js,how do you traverse the object inheritance tree using super()? ember.js错误:断言失败:来自findAll的响应必须是一个数组,而不是未定义 - ember.js Error: Assertion Failed: The response from a findAll must be an Array, not undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM