Search code examples
sproutcore

store.loadRecords only puts last record in store


I am putting together my first Sproutcore app. I have a simple model, a controller and a view. When I add a new record using store.createRecord() or .createRecords() they get added to the store, the controller and the view.

However, when I try to add new records via store.loadRecords() (from a remote source) from the response (e.g. [{"name":"test1"},{"name":"test2"},{"name":"test3"}]), only the last of the records (test3 in this case) ends up in the store. How can I change store.loadRecords() to actually add all the records?


Solution

  • Found the problem: I did not define the primaryKey in the Model. "primaryKey: 'id'," As easy as that.