根据 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] })