在Ember Data中,如何找到只加载的记录? [英] In Ember Data, how do I find only records that have been loaded?

查看:90
本文介绍了在Ember Data中,如何找到只加载的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档:

http://emberjs.com/guides/ember-data-lifecycle/

如果白垩数据将自动查找持久层以获取记录没有加载,我怎么只能找到甚至 findAll 已经加载的记录?

Ember data will automatically look to the persistent layer for a record if it's not loaded, how do I only find or even findAll records that have been loaded?

除了创建加载记录的非持久性列表,并在那里查找记录?

Aside from creating a non-persistent list of loaded records, and look for the record there?

推荐答案

p>你可以通过一个过滤器来实现:

You can do this via a filter:

App.Post.filter(function(post) { return post.get('isLoaded'); });

这将保留最新的只有应用程序的数组。发布已经加载的记录。加载新记录时,它将自动更新(并更新绑定到其上的任何DOM)。

This will keep an up-to-date Array of only the App.Post records that have been loaded. When new records are loaded, it will automatically update (and update any DOM that is bound to it).

这篇关于在Ember Data中,如何找到只加载的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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