Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addRecordData(recordData: RelationshipRecordData) {
if (this.members.has(recordData)) {
return;
}
// TODO Igor cleanup
assertPolymorphicType(this.recordData, this.relationshipMeta, recordData, this.store);
if (this.inverseRecordData) {
this.removeRecordData(this.inverseRecordData);
}
this.inverseRecordData = recordData;
super.addRecordData(recordData);
this.notifyBelongsToChange();
}
addRecordData(recordData: RelationshipRecordData, idx?: number) {
if (this.members.has(recordData)) {
return;
}
// TODO Type this
assertPolymorphicType(this.recordData, this.relationshipMeta, recordData, this.store);
super.addRecordData(recordData, idx);
// make lazy later
if (idx === undefined) {
idx = this.currentState.length;
}
this.currentState.splice(idx, 0, recordData);
// TODO Igor consider making direct to remove the indirection
// We are not lazily accessing the manyArray here because the change is coming from app side
// this.manyArray.flushCanonical(this.currentState);
this.notifyHasManyChange();
}
return resolve(objectOrPromise).then(data => {
let record;
if (DEPRECATE_BELONGS_TO_REFERENCE_PUSH && peekRecordIdentifier(data)) {
deprecate('Pushing a record into a BelongsToReference is deprecated', false, {
id: 'ember-data:belongs-to-reference-push-record',
until: '4.0',
});
record = data;
} else {
record = this.store.push(data);
}
assertPolymorphicType(
this.internalModel,
this.belongsToRelationship.relationshipMeta,
record._internalModel,
this.store
);
//TODO Igor cleanup, maybe move to relationship push
this.belongsToRelationship.setCanonicalRecordData(recordDataFor(record));
return record;
});
}
let internalModels = array.map(obj => {
let record = this.store.push(obj);
if (DEBUG) {
let relationshipMeta = this.hasManyRelationship.relationshipMeta;
assertPolymorphicType(this.internalModel, relationshipMeta, record._internalModel, this.store);
}
return recordDataFor(record);
});