2012-10-01 3 views
1

나는 엠버 데이터와 첫 hasMany의 관계를하고 공격있어이 보통 내가이 "엠"친숙한 형식으로 부르는에서 JSON 구조가없는 것을 의미엠버 데이터 "findMany"가 사이드로드해야하는 json 구조는 무엇입니까?

"Uncaught Error: assertion failed: Your server returned a hash with the key 0 but you have no mappings"

항상 재미.

장고 rest 프레임 워크를 사용하여 django 용 REST 어댑터를 직접 구축하고 있으므로 사이드로드에 오류가 없는지 궁금합니다.

현재 돌아 오는 JSON은 아래 (다시 분명히 어떤 넥타이 세션입니다하지만 어쩌면 타다가 이미이를 묶는 방법을 알고?)

[{"id": 2, "name": "FooBar"}]

모델이

CodeCamp.Session = DS.Model.extend({ 
    id: DS.attr('number'), 
    name: DS.attr('string'), 
    room: DS.attr('string'), 
    desc: DS.attr('string') 
});     

CodeCamp.Speaker = DS.Model.extend({ 
    id: DS.attr('number'), 
    name: DS.attr('string'), 
    session: DS.belongsTo('CodeCamp.Session') 
}); 

CodeCamp.Session.reopen({ 
    speakers: DS.hasMany('CodeCamp.Speaker') 
}); 
모습처럼 보인다

답변

1

json으로 구조가이

0과 같아야합니다 사전에 감사합니다 이 그게 내가 그냥 이름 DICT 안에 내 JSON을 포장하는 데 필요한 보여줍니다 커밋을 찾을 수 1,237,413,869,878,

https://github.com/Kurki/data/commit/f59ad5bc9718634b6f3d59356deae0bf97a1bbd5

그래서 이것은 내 사용자 지정 JSON 방법은 내 장고 어댑터에 지금

findMany: function(store, type, ids) { 
              var root = this.rootForType(type), plural = this.pluralize(root), json = {}; 
              this.django_ajax(this.buildURL(root, ids), "GET", { 
                success: function(pre_json) { 
        json[plural] = pre_json;                  
                   this.sideload(store, type, json, plural); 
                   store.loadMany(type, json[plural]); 
             } 
           }); 
       } 
관련 문제