Open ef4 opened 2 years ago
If you have a key defined on your Organization
model (@key() remoteId;
) and relationship data is included with the primary model's data, then I believe that a minimalist record (with just type
, id
, and remoteId
) of type organization
should exist in your cache after processing that payload. If that's true, then you should be able to access it through your model via this.organization.remoteId
.
I may be missing some context here. Is this.organization
not present? Was it explicitly deleted? Do you have any inverse relationships present?
Oh, interesting! I was just assuming this.organization would be undefined. I will try that.
I got a chance to try this, and it's unreliable.
It works if the related record happened to already load via other means. But if the record is not loaded, remoteId
is not present. Only type
and id
are present.
https://github.com/orbitjs/ember-orbit/pull/403 has a passing test to demonstrate the loaded case and a failing test for the unloaded case.
Given a server that includes data references for unloaded relationships:
Is there public API for accessing the data.type and data.id from an ember-orbit model?
I was able to work around by creating a getter on my model: