-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(repository): add interface for hasManyThrough repository #4312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
derdeka
merged 1 commit into
loopbackio:master
from
KalleV:kv_add_has_many_through_repository_interface
Jan 14, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
packages/repository/src/relations/has-many/has-many-through.repository.ts
This file contains hidden or 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,100 @@ | ||
| // Copyright IBM Corp. 2020. All Rights Reserved. | ||
| // Node module: @loopback/repository | ||
| // This file is licensed under the MIT License. | ||
| // License text available at https://opensource.org/licenses/MIT | ||
|
|
||
| import {Count, DataObject, Entity, Filter, Options, Where} from '../..'; | ||
|
|
||
| /** | ||
| * CRUD operations for a target repository of a HasManyThrough relation | ||
| * | ||
| * EXPERIMENTAL: This interface is not stable and may change in the near future. | ||
| * Backwards-incompatible changes may be introduced in semver-minor versions. | ||
| */ | ||
KalleV marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export interface HasManyThroughRepository< | ||
| Target extends Entity, | ||
| TargetID, | ||
| Through extends Entity | ||
| > { | ||
| /** | ||
| * Create a target model instance | ||
| * @param targetModelData - The target model data | ||
| * @param options - Options for the operation | ||
| * @returns A promise which resolves to the newly created target model instance | ||
| */ | ||
| create( | ||
| targetModelData: DataObject<Target>, | ||
KalleV marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| options?: Options & { | ||
| throughData?: DataObject<Through>; | ||
| throughOptions?: Options; | ||
| }, | ||
| ): Promise<Target>; | ||
KalleV marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Find target model instance(s) | ||
| * @param filter - A filter object for where, order, limit, etc. | ||
| * @param options - Options for the operation | ||
| * @returns A promise which resolves with the found target instance(s) | ||
| */ | ||
| find( | ||
| filter?: Filter<Target>, | ||
| options?: Options & { | ||
| throughOptions?: Options; | ||
| }, | ||
| ): Promise<Target[]>; | ||
|
|
||
| /** | ||
| * Delete multiple target model instances | ||
| * @param where - Instances within the where scope are deleted | ||
| * @param options | ||
| * @returns A promise which resolves the deleted target model instances | ||
| */ | ||
| delete( | ||
| where?: Where<Target>, | ||
| options?: Options & { | ||
| throughOptions?: Options; | ||
| }, | ||
| ): Promise<Count>; | ||
|
|
||
| /** | ||
| * Patch multiple target model instances | ||
| * @param dataObject - The fields and their new values to patch | ||
| * @param where - Instances within the where scope are patched | ||
| * @param options | ||
| * @returns A promise which resolves the patched target model instances | ||
| */ | ||
| patch( | ||
| dataObject: DataObject<Target>, | ||
| where?: Where<Target>, | ||
| options?: Options & { | ||
| throughOptions?: Options; | ||
| }, | ||
| ): Promise<Count>; | ||
|
|
||
| /** | ||
| * Creates a new many-to-many association to an existing target model instance | ||
| * @param targetModelId - The target model ID to link | ||
| * @param options | ||
| * @returns A promise which resolves to the linked target model instance | ||
| */ | ||
| link( | ||
| targetModelId: TargetID, | ||
| options?: Options & { | ||
| throughData?: DataObject<Through>; | ||
| throughOptions?: Options; | ||
| }, | ||
KalleV marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ): Promise<Target>; | ||
|
|
||
| /** | ||
| * Removes an association to an existing target model instance | ||
| * @param targetModelId - The target model to unlink | ||
| * @param options | ||
| * @returns A promise which resolves to null | ||
| */ | ||
| unlink( | ||
| targetModelId: TargetID, | ||
| options?: Options & { | ||
| throughOptions?: Options; | ||
| }, | ||
| ): Promise<void>; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.