当从Node + Express REST服务器获取JSON时,Ember数据会中断

我正尝试从Node.js和Express构build的REST服务器中获取JSON数据,然后在我的Ember#Route中将其用作模型。

我试图获取的数据:

var books = [ { id: 98, author: 'Stanisław Lem', title: 'Solaris' }, { id: 99, author: 'Andrzej Sapkowski', title: 'Wiedźmin' } ]; 

我使用的模型:

 App.Book = DS.Model.extend({ id: DS.attr('number'), author: DS.attr('string'), title: DS.attr('string') }); 

我这样设置RESTAdapter:

 App.ApplicationAdapter = DS.RESTAdapter.extend({ host: 'http://localhost:8080' }); 

制图:

 App.Router.map(function () { this.resource("books"); }); 

我的路线如下所示:

 App.BooksRoute = Ember.Route.extend({ model: function () { return this.store.find('book'); } }); 

我知道,当涉及到JSON文件时,ember-data遵循一定的惯例。 我的服务器以这种方式提供JSON:

 app.get('/books', function (request, response) { console.log('In GET function '); response.json({'books': books}) }); 

然后,进入后

 http://localhost:8080/books 

我明白了

 {"books":[{"id":98,"author":"Stanisław Lem","title":"Solaris"},{"id":99,"author":"Andrzej Sapkowski","title":"Wiedźmin"}]} 

但是当我进入

 http://localhost:8080/#/books 

烬数据抛出长的错误列表,开始于:

 "Error while processing route: books" "invalid 'in' operand record._attributes" "ember$data$lib$system$model$attributes$$getValue@http://localhost:8080/static/ember-data.js:8176:1 ember$data$lib$system$model$attributes$$attr/<@http://localhost:8080/static/ember-data.js:8202:26 computedPropertySet@http://localhost:8080/static/ember.prod.js:11882:15 computedPropertySetWithSuspend@http://localhost:8080/static/ember.prod.js:11842:9 makeCtor/Class@http://localhost:8080/static/ember.prod.js:33887:17 ... 

现在我不知道什么是错的,如何解决这个问题。

看起来我犯的错误是在声明模型。 ID属性不应该在这里声明,正确的模型看起来像这样:

 App.Book = DS.Model.extend({ author: DS.attr('string'), title: DS.attr('string') });