Skip to content

Instantly share code, notes, and snippets.

@jimdalbano
Last active December 14, 2015 11:19
Show Gist options
  • Save jimdalbano/5077916 to your computer and use it in GitHub Desktop.
Save jimdalbano/5077916 to your computer and use it in GitHub Desktop.
// Override DS.Adapter.didFindQuery only so that we can change the
// loader.populateArray function. Unfortunately, we can't just twiddle
// the populateArray function and let _super do the work. A hook would be nice.
didFindQuery: function(store, type, payload, recordArray) {
var loader = DS.loaderFor(store);
// ========================================
// Here's the only difference!
//
if (type.toString() === 'App.Photo') {
if (payload.stat === 'ok') {
// bit of an assumption here.
recordArray.set('page', payload.photos.page);
recordArray.set('perPage', payload.photos.perpage);
recordArray.set('pages', payload.photos.pages);
recordArray.set('total', payload.photos.total);
}
payload = { 'photos' : payload.photos.photo };
}
// ========================================
loader.populateArray = function(data) {
recordArray.load(data);
};
get(this, 'serializer').extractMany(loader, payload, type);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment