Last active
December 9, 2022 20:41
-
-
Save amk221/478038bfd5f5460d6074ce183f7d3c07 to your computer and use it in GitHub Desktop.
ED meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Model from 'ember-data/model'; | |
import attr from 'ember-data/attr'; | |
export default class FooModel extends Model { | |
@attr('string') name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
import { inject } from '@ember/service'; | |
export default class extends Route { | |
@inject store; | |
model() { | |
const restPayload = { | |
foo: { | |
id: 1, | |
name: 'Foo 1' | |
}, | |
meta: { | |
foo: 'bar' | |
} | |
}; | |
const Foo = this.store.modelFor('foo'); | |
const fooSerializer = this.store.serializerFor('foo'); | |
const jsonApiPayload = fooSerializer.normalizeResponse(this.store, Foo, restPayload, null, 'findRecord'); | |
this.store.push(jsonApiPayload); | |
const foo1 = this.store.peekRecord('foo', 1); | |
console.log('Got meta?', foo1.meta); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RESTSerializer from 'ember-data/serializers/rest'; | |
export default class FooSerializer extends RESTSerializer { | |
extractMeta() { | |
const meta = super.extractMeta(...arguments); | |
console.log('Found meta', meta); | |
return meta; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.17.1", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js", | |
"ember": "3.18.1", | |
"ember-template-compiler": "3.18.1", | |
"ember-testing": "3.18.1" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0", | |
"ember-data": "3.18.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment