Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Mifrill/264e40f5697b6ca89cf5fa2d35612704 to your computer and use it in GitHub Desktop.
Save Mifrill/264e40f5697b6ca89cf5fa2d35612704 to your computer and use it in GitHub Desktop.
// https://gist.github.com/samselikoff/b00b5a190321c8236ee0e0fab200bf65
import { run } from '@ember/runloop';
export default function pushMirageDbIntoStore(server, store) {
const tables = Object.keys(server.schema);
tables.forEach((table) => {
if (server.schema[table].all) {
const all = server.schema[table].all();
const modelName = all.modelName;
const serializer = server.serializerOrRegistry.serializerFor(modelName);
const originalAlwaysIncludeLinkageData = serializer.alwaysIncludeLinkageData;
serializer.alwaysIncludeLinkageData = true;
const json = serializer.serialize(all);
serializer.alwaysIncludeLinkageData = originalAlwaysIncludeLinkageData;
run(() => {
store.pushPayload(json);
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment