Skip to content

Instantly share code, notes, and snippets.

@rondale-sc
Created October 25, 2016 20:27
Show Gist options
  • Select an option

  • Save rondale-sc/6bebec33349249387e9492492b3280da to your computer and use it in GitHub Desktop.

Select an option

Save rondale-sc/6bebec33349249387e9492492b3280da to your computer and use it in GitHub Desktop.
model(params) {
let shoebox = this.get('fastboot.shoebox');
let shoeboxStore = shoebox.retrieve('my-store');
if (this.get('fastboot.isFastBoot')) {
return this.store.queryRecord('episode', { slug: params.slug }).then(episode => {
if(!shoeboxStore){
shoeboxStore = {};
shoebox.put('my-store', shoeboxStore);
}
const pushData = episode.serialize({includeId: true});
const includeds = [];
episode.get('showNotes').map(function(showNote) {
includeds.push(showNote.serialize({includeId: true}).data);
includeds.push(showNote.get('resource').serialize({includeId: true}).data);
showNote.get('authors').map(function(author) {
includeds.push(author.serialize({includeId: true}).data);
});
});
pushData.included = includeds;
shoeboxStore[params.slug] = pushData
});
} else {
const pushData = shoeboxStore[params.slug];
this.store.pushPayload(pushData);
const model = this.store.peekRecord('episode', pushData.data.id);
return model;
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment