0
我收到以下錯誤造成類型錯誤,而使用DS.EmbeddedRecordsMixin
時,我的記錄已嵌入數據:EmbeddedRecordsMixin的hasMany嵌入式記錄
TypeError: Cannot read property 'typeKey' of undefined
我用灰燼CLI 0.1.2與Ember 1.7.0和灰燼數據1.0.0#beta11
我的適配器:
應用適配器 - /app/adapters/application.js(RestAdapter):
import DS from 'ember-data';
import config from '../config/environment';
export default DS.RESTAdapter.extend({
namespace: config.APP.RestAdapterNamespace,
host: config.APP.SERVER_LOCATION
});
適配器中的問題 - /app/adapters/screen.js(screenSlideGroups
應該嵌入):
import ApplicationAdapter from './application';
import DS from 'ember-data';
export default ApplicationAdapter.extend(DS.EmbeddedRecordsMixin, {
attrs: {
screenSlideGroups: { embedded: 'always' }
}
});
型號:/app/models/screen.js數據的
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
path: DS.attr('string'),
screenSlideGroups: DS.hasMany('screen-slide-group')
});
實施例從API返回:
{
"screen":[
{
"id":1,
"name":"Weather",
"path":"weather",
"screenSlideGroups":[
{
"id":1,
"screen":1,
"slideGroup":1,
"order":1
}
],
"lastUpdated":"2014-09-18T18:26:25.69"
},
{
"id":2,
"name":"Front Lobby",
"path":"frontlobby",
"screenSlideGroups":[
],
"lastUpdated":"0001-01-01T00:00:00"
}
]
}
我也嘗試從嵌入式記錄刪除screen
,櫃面背病房的參考可能會把它搞砸,但它沒有什麼區別。據我所知,我創建的EmbeddedRecordsMixin適配器可能根本無法使用。
對此可能出錯的任何想法?