-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(repository): hasManyThrough - add HasManyThroughRepositoryFactory
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/repository/src/relations/has-many/has-many-through-repository.factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {Entity, EntityCrudRepository, Getter, HasManyThroughDefinition} from "../.."; | ||
import {DefaultHasManyThroughRepository, HasManyThroughRepository} from "./has-many-through.repository"; | ||
|
||
export type HasManyThroughRepositoryFactory< | ||
TargetEntity extends Entity, | ||
TargetID, | ||
ThroughEntity extends Entity, | ||
ThroughID, | ||
> = (fkValue: ThroughID) => HasManyThroughRepository<TargetEntity, TargetID, ThroughEntity>; | ||
|
||
export function createHasManyThroughRepositoryFactory< | ||
TargetEntity extends Entity, | ||
TargetID, | ||
ThroughEntity extends Entity, | ||
ThroughID, | ||
>( | ||
relationMetadata: HasManyThroughDefinition, | ||
targetRepositoryGetter: Getter<EntityCrudRepository<TargetEntity, TargetID>>, | ||
throughRepositoryGetter: Getter<EntityCrudRepository<ThroughEntity, ThroughID>>, | ||
): HasManyThroughRepositoryFactory<TargetEntity, TargetID, ThroughEntity, ThroughID> { | ||
return (fkValue?: ThroughID) => { | ||
return new DefaultHasManyThroughRepository< | ||
TargetEntity, | ||
TargetID, | ||
EntityCrudRepository<TargetEntity, TargetID>, | ||
ThroughEntity, | ||
ThroughID, | ||
EntityCrudRepository<ThroughEntity, ThroughID> | ||
>( | ||
targetRepositoryGetter, | ||
throughRepositoryGetter, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters