I receive a response from the server similar to this:
{"entity":"group","entityId":"myId1" }
Now I would reflect that in ember data in a way similar to this, so that entity determines the type of object, that is referenced by the entityId:
export default DS.Model.extend({
entity: DS.attr({ type: 'string' }),
entityId: DS.belongsTo(this.entity, { relatedType: this.entity }),
});
However, this does not work as the belongsTo relationship is resolved before the entity has been set and therefor is undefined, leading to ember data expecting a model with name entityId, which obviously does not exist. Is there a way to get this working without too much trouble?