Ember-Data로 Fixture Adapter를 사용하는 어플리케이션을 개발하려고합니다.Ember-Data에서 generateIdForRecord에 액세스하는 방법은 무엇입니까?
내가 정의한 모델을 기반으로 새 객체를 만들 때 ID를 지정하지 않으면 작동하지 않습니다. 나는 ID를 지정 할 경우
이 :
var person = SD.Person.createRecord({
id: 234,
name: "test"
});
var person.save();
내가 얻을 :
가 아니에요 (어떻게 든 기존의 기록을 갱신하는 것 같은 소리를 만드는Error: assertion failed: An adapter cannot assign a new id to a record that already has an id. had id: 234 and you tried to update it with 234. This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.
, 거기에 ID가 각각 1과 2 인 Person 개체에 대해서만 2 개의 조명기).
Ember가 내 개체를 어떻게 든 두 번 저장하려고합니까?
나는 ID를 설정하기 위해 generateIdForRecord을 사용해 봐야한다고 생각했지만 시도한대로이 기능을 참조 할 수는 없습니다. 내가 엠버와 엠버 - 데이터의 최신 버전을 사용하고
newBooking.set('id', this.store.generateIdForRecord(this.store, newBooking));
newBooking.set('id', DS.generateIdForRecord(this.store, newBooking));
newBooking.set('id', this.generateIdForRecord(this.store, newBooking));
newBooking.set('id', generateIdForRecord(this.store, newBooking));
TypeError: this.store.generateIdForRecord is not a function
(도 이전 릴리스를 시도했다). 제 모델은 Ember 가이드의 TodoMVC 튜토리얼과 다르게 구현됩니다. 튜토리얼에서는 Fixture 어댑터로 ID를 관리하기 위해 어떤 일을해야 할 필요가 없으므로 실제로 어떤 일이 일어나는지 전혀 알지 못합니다. 내 예에 따라 (새로운 Person 객체를 만들려면 어떻게해야합니까
, 하나의 '이름'필드는 상기 오류없이 엠버 - 데이터의 고정 어댑터를 사용하여 지속? 결국
네임 스페이스에 'SD'가 무엇입니까? – intuitivepixel
@in tuitivepixel - SD에서 내 앱을 만들었습니다. 질문에 대한 업데이트를 게시하려고했지만 첫 번째 코드 조각이 실제로 작동합니다. 왠지 나는 그것을 콘솔에서 이벤트로보기를 기대하고있었습니다. 결국 개체가 생성되었습니다. – Anonymous