Skip to content

Commit

Permalink
feat(repository): add interface for hasManyThrough repository
Browse files Browse the repository at this point in the history
The hasManyThrough repository interface defines the actions that can be performed on a many-to-many model relation.

This PR is a continuation of loopbackio#2359 and implements a step from loopbackio#2359 (comment).
  • Loading branch information
kv979w committed Dec 16, 2019
1 parent e94d0e6 commit a85974a
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {Entity, DataObject, Options, Filter, Where, Count} from '../..';

/**
* CRUD operations for a target repository of a HasManyThrough relation
*/
export interface HasManyThroughRepository<
Target extends Entity,
Through extends Entity
> {
/**
* Create a target model instance
* @param targetModelData - The target model data
* @param throughModelData - The through model data
* @param options - Options for the operation
* @param throughOptions - Options passed to create through
* @returns A promise which resolves to the newly created target model instance
*/
create(
targetModelData: DataObject<Target>,
throughModelData?: DataObject<Through>,
options?: Options,
throughOptions?: Options,
): Promise<Target>;
/**
* 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>;
}

0 comments on commit a85974a

Please sign in to comment.