【发布时间】:2012-04-30 14:32:09
【问题描述】:
根据ember-data中实现的测试,当我们从hasMany关系中请求子记录时,store对子资源url进行get GET,并发送需要的子资源的id。
test("finding many people by a list of IDs", function() {
store.load(Group, { id: 1, people: [ 1, 2, 3 ] });
var group = store.find(Group, 1);
equal(ajaxUrl, undefined, "no Ajax calls have been made yet");
var people = get(group, 'people');
equal(get(people, 'length'), 3, "there are three people in the association already");
people.forEach(function(person) {
equal(get(person, 'isLoaded'), false, "the person is being loaded");
});
expectUrl("/people");
expectType("GET");
expectData({ ids: [ 1, 2, 3 ] });
如何发送父记录(组)的 id ?我的服务器需要这个 id 来检索嵌入的记录。它需要类似的东西:
expectData({groud_id: the_group_id, ids: [1,2,3] })
【问题讨论】:
标签: ember.js ember-data