1 | import { Getter } from '@loopback/core';
|
2 | import { Filter, Where } from '@loopback/filter';
|
3 | import { Count, DataObject, Options } from '../../common-types';
|
4 | import { Entity } from '../../model';
|
5 | import { EntityCrudRepository } from '../../repositories';
|
6 | /**
|
7 | * CRUD operations for a target repository of a HasMany relation
|
8 | */
|
9 | export interface HasManyRepository<Target extends Entity> {
|
10 | /**
|
11 | * Create a target model instance
|
12 | * @param targetModelData - The target model data
|
13 | * @param options - Options for the operation
|
14 | * @returns A promise which resolves to the newly created target model instance
|
15 | */
|
16 | create(targetModelData: DataObject<Target>, options?: Options): Promise<Target>;
|
17 | /**
|
18 | * Find target model instance(s)
|
19 | * @param filter - A filter object for where, order, limit, etc.
|
20 | * @param options - Options for the operation
|
21 | * @returns A promise which resolves with the found target instance(s)
|
22 | */
|
23 | find(filter?: Filter<Target>, options?: Options): Promise<Target[]>;
|
24 | /**
|
25 | * Delete multiple target model instances
|
26 | * @param where - Instances within the where scope are deleted
|
27 | * @param options
|
28 | * @returns A promise which resolves the deleted target model instances
|
29 | */
|
30 | delete(where?: Where<Target>, options?: Options): Promise<Count>;
|
31 | /**
|
32 | * Patch multiple target model instances
|
33 | * @param dataObject - The fields and their new values to patch
|
34 | * @param where - Instances within the where scope are patched
|
35 | * @param options
|
36 | * @returns A promise which resolves the patched target model instances
|
37 | */
|
38 | patch(dataObject: DataObject<Target>, where?: Where<Target>, options?: Options): Promise<Count>;
|
39 | }
|
40 | export declare class DefaultHasManyRepository<TargetEntity extends Entity, TargetID, TargetRepository extends EntityCrudRepository<TargetEntity, TargetID>> implements HasManyRepository<TargetEntity> {
|
41 | getTargetRepository: Getter<TargetRepository>;
|
42 | constraint: DataObject<TargetEntity>;
|
43 | /**
|
44 | * Constructor of DefaultHasManyEntityCrudRepository
|
45 | * @param getTargetRepository - the getter of the related target model repository instance
|
46 | * @param constraint - the key value pair representing foreign key name to constrain
|
47 | * the target repository instance
|
48 | */
|
49 | constructor(getTargetRepository: Getter<TargetRepository>, constraint: DataObject<TargetEntity>);
|
50 | create(targetModelData: DataObject<TargetEntity>, options?: Options): Promise<TargetEntity>;
|
51 | find(filter?: Filter<TargetEntity>, options?: Options): Promise<TargetEntity[]>;
|
52 | delete(where?: Where<TargetEntity>, options?: Options): Promise<Count>;
|
53 | patch(dataObject: DataObject<TargetEntity>, where?: Where<TargetEntity>, options?: Options): Promise<Count>;
|
54 | }
|