Class RelationshipPayloads private
Manages the payloads for both sides of a single relationship, across all model instances.
For example, with
const User = DS.Model.extend({ hobbies: DS.hasMany('hobby') });
const Hobby = DS.Model.extend({ user: DS.belongsTo('user') });
let relationshipPayloads = new RelationshipPayloads('user', 'hobbies', 'hobby', 'user');
let userPayload = { data: { id: 1, type: 'user', relationships: { hobbies: { data: [{ id: 2, type: 'hobby', }] } } } };
// here we expect the payload of the individual relationship relationshipPayloads.push('user', 1, 'hobbies', userPayload.data.relationships.hobbies);
relationshipPayloads.get('user', 1, 'hobbies'); relationshipPayloads.get('hobby', 2, 'user');
Methods
_isLHS : Boolean
Defined in addon/-private/system/relationships/relationship-payloads.js:141
- returns
- Boolean
true iff
modelNameandrelationshipNamerefer to the left hand side of this relationship, as opposed to the right hand side.
_isRHS : Boolean
Defined in addon/-private/system/relationships/relationship-payloads.js:161
- returns
- Boolean
true iff
modelNameandrelationshipNamerefer to the right hand side of this relationship, as opposed to the left hand side.
_removeFromInverse
Defined in addon/-private/system/relationships/relationship-payloads.js:381
Remove id from its inverse record with id inverseId. If the inverse
relationship is a belongsTo, this means just setting it to null, if the
inverse relationship is a hasMany, then remove that id from its array of ids.
_removeInverse
Defined in addon/-private/system/relationships/relationship-payloads.js:350
Remove the relationship in previousPayload from its inverse(s), because
this relationship payload has just been updated (eg because the same
relationship had multiple payloads pushed before the relationship was
initialized).
get
Defined in addon/-private/system/relationships/relationship-payloads.js:93
Get the payload for the relationship of an individual record.
This might return the raw payload as pushed into the store, or one computed from the payload of the inverse relationship.
push
Defined in addon/-private/system/relationships/relationship-payloads.js:112
Push a relationship payload for an individual record.
This will make the payload available later for both this relationship and its inverse.
unload
Defined in addon/-private/system/relationships/relationship-payloads.js:123
Unload the relationship payload for an individual record.
This does not unload the inverse relationship payload.