Skip to content

Instantly share code, notes, and snippets.

@joachimhs
Created May 23, 2012 08:21
Show Gist options
  • Save joachimhs/2773865 to your computer and use it in GitHub Desktop.
Save joachimhs/2773865 to your computer and use it in GitHub Desktop.
No Primary Key
Model:
MyApp.Photo = DS.Model.extend({
primaryKey: 'id',
id: DS.attr('string'),
photoName: DS.attr('string'),
photoDescription: DS.attr('string'),
photoFullSizeURL: DS.attr('string'),
photoThumbnailURL: DS.attr('string')
});
JSON retrieved from server:
[
{
"id": "1",
"photoName": "Bird Photo",
"photoDescription": "Bird Photo Description",
"photoFullSizeUrl": "photos/bird.jpg",
"photoThumbnailUrl": "photos/bird_thumb.png"
}
]
Adaptor for findAll:
MyApp.Adapter = DS.Adapter.create({
findAll: function(store, type) {
var url = type.url;
jQuery.getJSON(url, function(data) {
console.log('getting from url: ' + url + ' length: ' + data.length);
store.loadMany(type, data);
});
}
});
Error Message:
Error: assertion failed: A data hash was loaded for a model of type MyApp.Photo but no primary key 'undefined' was provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment