diff --git a/src/db/ModelRelation.ts b/src/db/ModelRelation.ts index 1ffb0ff..6a1c54b 100644 --- a/src/db/ModelRelation.ts +++ b/src/db/ModelRelation.ts @@ -222,7 +222,7 @@ export class RecursiveModelRelation extends ManyModelRelation !this.cachedModels!.find(cached => cached.equals(model)) && 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); if (this.reverse) this.cachedModels!.reverse();