合并两个记录数组 [英] Merge two Record Arrays
问题描述
我的应用程序中有两种不同的模型:
I have two different models in my application
App.Foo = DS.Model.extend({
title: DS.attr('string')
});
App.Bar = DS.Model.extend({
title: DS.attr('string')
});
foo和bar模型都可以从后端的不同模型获取数据。
他们都有一些常见的领域,如标题。但是其他的也是不一样的(而且我将需要不同的意见)。
Both foo and bar models get their data from different models in my backend.
They both have some common fields, like title. But others are also different (and I will need different views for them).
但是,当显示它们的列表时,我希望能够合并它们订购它们,就像它们是相同的对象。
However, when displaying a list of them, I would like to be able to merge them and order them as if they were the same object.
不幸的是,我在ember-data codebase中看到的似乎是不可能的。
解决方案的任何想法?
Unfortunately from what I see in the ember-data codebase, that doesn't seem to be possible.
Any idea on solutions ?
推荐答案
已经在最新版本的Ember Data中解决了 findAll 。
This has been solved in the latest versions of Ember Data with the implementation of findAll.
因此,我们可以做:
DS.store.findAll(DS.Model)
哪些将加载所有型号的所有记录。
Which will load all records from all models.
这篇关于合并两个记录数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!