ModelRelations: deduplicate recursive relations on populate()
This commit is contained in:
parent
969ab18b96
commit
b12d104c78
@ -222,7 +222,7 @@ export class RecursiveModelRelation<M extends Model> extends ManyModelRelation<M
|
|||||||
this.cachedModels.push(...models.filter(model =>
|
this.cachedModels.push(...models.filter(model =>
|
||||||
!this.cachedModels!.find(cached => cached.equals(model)) &&
|
!this.cachedModels!.find(cached => cached.equals(model)) &&
|
||||||
this.cachedModels!.find(cached => cached[this.dbProperties.localKey] === model[this.dbProperties.foreignKey])
|
this.cachedModels!.find(cached => cached[this.dbProperties.localKey] === model[this.dbProperties.foreignKey])
|
||||||
));
|
).reduce((array: M[], val) => array.find(v => v.equals(val)) ? array : [...array, val], []));
|
||||||
} while (count !== this.cachedModels.length);
|
} while (count !== this.cachedModels.length);
|
||||||
|
|
||||||
if (this.reverse) this.cachedModels!.reverse();
|
if (this.reverse) this.cachedModels!.reverse();
|
||||||
|
Loading…
Reference in New Issue
Block a user