Fix relation reducing mistakenly using "in" instead of indexOf >= 0
This commit is contained in:
parent
d3e3a86855
commit
15678e0381
@ -72,7 +72,7 @@ export default abstract class ModelRelation<S extends Model, O extends Model, R
|
||||
public async eagerLoad(relations: ModelRelation<S, O, R>[], subRelations: string[] = []): Promise<ModelQueryResult<O>> {
|
||||
const ids = relations.map(r => r.getModelID())
|
||||
.filter(id => id !== null && id !== undefined)
|
||||
.reduce((array: O[], val) => val in array ? array : [...array, val], []);
|
||||
.reduce((array: O[], val) => array.indexOf(val) >= 0 ? array : [...array, val], []);
|
||||
if (ids.length === 0) return [];
|
||||
|
||||
const query = this.makeQuery();
|
||||
@ -181,7 +181,7 @@ export class ManyThroughModelRelation<S extends Model, O extends Model> extends
|
||||
|
||||
public async eagerLoad(relations: ModelRelation<S, O, O[]>[], subRelations: string[] = []): Promise<ModelQueryResult<O>> {
|
||||
const ids = relations.map(r => r.getModelID())
|
||||
.reduce((array: O[], val) => val in array ? array : [...array, val], []);
|
||||
.reduce((array: O[], val) => array.indexOf(val) >= 0 ? array : [...array, val], []);
|
||||
if (ids.length === 0) return [];
|
||||
|
||||
const query = this.makeQuery();
|
||||
|
Loading…
Reference in New Issue
Block a user