-
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 - implement DefaultHasManyThroughRep…
…ository
- Loading branch information
Showing
5 changed files
with
191 additions
and
24 deletions.
There are no files selected for viewing
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
51 changes: 51 additions & 0 deletions
51
packages/repository/src/relations/has-many/has-many-through.helpers.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,51 @@ | ||
import {DataObject, Entity, HasManyThroughDefinition} from '../..'; | ||
|
||
export type HasManyThroughResolvedDefinition = HasManyThroughDefinition; | ||
|
||
/** | ||
* Creates constraint used to query target | ||
* @param relationMeta - hasManyThrough metadata to resolve | ||
* @param throughInstances - Instances of through entities used to constrain the target | ||
* @internal | ||
*/ | ||
export function createTargetConstraint< | ||
Target extends Entity, | ||
Through extends Entity | ||
>( | ||
relationMeta: HasManyThroughResolvedDefinition, | ||
throughInstances: Through[], | ||
): DataObject<Target> { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
/** | ||
* Creates constraint used to query through | ||
* @param relationMeta - hasManyThrough metadata to resolve | ||
* @param fkValue - Value of the foreign key used to constrain through | ||
* @param targetInstance - Instance of target entity used to constrain through | ||
* @internal | ||
*/ | ||
export function createThroughConstraint< | ||
Target extends Entity, | ||
Through extends Entity, | ||
ForeignKeyType | ||
>( | ||
relationMeta: HasManyThroughResolvedDefinition, | ||
fkValue?: ForeignKeyType, | ||
targetInstance?: Target, | ||
): DataObject<Through> { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
/** | ||
* Resolves given hasMany metadata if target is specified to be a resolver. | ||
* Mainly used to infer what the `keyTo` property should be from the target's | ||
* belongsTo metadata | ||
* @param relationMeta - hasManyThrough metadata to resolve | ||
* @internal | ||
*/ | ||
export function resolveHasManyThroughMetadata( | ||
relationMeta: HasManyThroughDefinition, | ||
): HasManyThroughResolvedDefinition { | ||
throw new Error('Not implemented'); | ||
} |
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
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
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