Skip to content

Commit

Permalink
feat(repository): hasManyThrough - add createHasManyThroughRepository…
Browse files Browse the repository at this point in the history
…FactoryFor
  • Loading branch information
derdeka committed Jan 21, 2020
1 parent 461160b commit cc8d66e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/repository/src/repositories/legacy-juggler-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import {
HasOneRepositoryFactory,
includeRelatedModels,
InclusionResolver,
HasManyThroughDefinition,
HasManyThroughRepositoryFactory,
createHasManyThroughRepositoryFactory,
} from '../relations';
import {IsolationLevel, Transaction} from '../transaction';
import {isTypeResolver, resolveType} from '../type-resolver';
Expand Down Expand Up @@ -262,6 +265,29 @@ export class DefaultCrudRepository<
);
}

protected createHasManyThroughRepositoryFactoryFor<
TargetEntiy extends Entity,
TargetID,
ThroughEntity extends Entity,
ThroughID,
>(
relationName: string,
targetRepositoryGetter: Getter<EntityCrudRepository<TargetEntiy, TargetID>>,
throughRepositoryGetter: Getter<EntityCrudRepository<ThroughEntity, ThroughID>>,
): HasManyThroughRepositoryFactory<TargetEntiy, TargetID, ThroughEntity, ThroughID> {
const meta = this.entityClass.definition.relations[relationName];
return createHasManyThroughRepositoryFactory<
TargetEntiy,
TargetID,
ThroughEntity,
ThroughID
>(
meta as HasManyThroughDefinition,
targetRepositoryGetter,
throughRepositoryGetter,
);
}

/**
* @deprecated
* Function to create a belongs to accessor
Expand Down

0 comments on commit cc8d66e

Please sign in to comment.