Backbone.js: Collection containing multiple Models with same ID
I would suggest that on both Album and Photo, you add the following:
idAttribute: 'uniqueId'
parse: function(response) {
response.uniqueId = type+'_'+response.id
return response;
}
Since version 1.2 you can use Collection.modelId
to specify how your collection will uniquely identify models. In your case, you can do the following to ensure that your types have different IDs.
var MyCollection = Backbone.Collection.extend({
modelId: function (attrs) {
return attrs.type + "-" + attrs.id;
}
// ...
})