ember-data-model-fragments
ember-data-model-fragments copied to clipboard
Polymorphic fragmentArray and typeKey
Hi
I used to be able to do this on a polymorphic model to get to the typekey given as argument in the model definition
const typeKey = this.contactModel.get('options.typeKey');
Currently (6.0.1) these event options is undefined. Did ember data remove that? I'm still using ember and ember-data 3.28.12
@fragmentArray('fragment/contact/contactcomponent', {
polymorphic: true,
typeKey: 'componentType',
...
In model-fragments v5, FragmentArray
exposed an options
property containing the attribute metadata, although it was private API:
https://github.com/adopted-ember-addons/ember-data-model-fragments/blob/7ea57179eff9063530ac4fd42097604540887f25/addon/array/fragment.js#L82
In model-fragments v6, you can get a fragment array's attribute metadata the same way you would do for any regular attr
:
So you could do something like:
modelInstance.constructor.attributes.get('fragmentArrayAttr').options