import { Query, Class, Filter, AggregateQuery, AggregateResponse, ModifyRelationOptions, FindRelationOptions, GetByIdOptions } from '@nestjs-query/core'; import { Repository } from 'typeorm'; import { FilterQueryBuilder, RelationQueryBuilder } from '../query'; /** * Base class to house relations loading. * @internal */ export declare abstract class RelationQueryService { abstract filterQueryBuilder: FilterQueryBuilder; abstract EntityClass: Class; abstract repo: Repository; abstract getById(id: string | number, opts?: GetByIdOptions): Promise; /** * Query for relations for an array of Entities. This method will return a map with the Entity as the key and the relations as the value. * @param RelationClass - The class of the relation. * @param relationName - The name of the relation to load. * @param entities - the dtos to find relations for. * @param query - A query to use to filter, page, and sort relations. */ queryRelations(RelationClass: Class, relationName: string, entities: Entity[], query: Query): Promise>; /** * Query for an array of relations. * @param RelationClass - The class to serialize the relations into. * @param dto - The dto to query relations for. * @param relationName - The name of relation to query for. * @param query - A query to filter, page and sort relations. */ queryRelations(RelationClass: Class, relationName: string, dto: Entity, query: Query): Promise; aggregateRelations(RelationClass: Class, relationName: string, entities: Entity[], filter: Filter, aggregate: AggregateQuery): Promise[]>>; aggregateRelations(RelationClass: Class, relationName: string, dto: Entity, filter: Filter, aggregate: AggregateQuery): Promise[]>; countRelations(RelationClass: Class, relationName: string, entities: Entity[], filter: Filter): Promise>; countRelations(RelationClass: Class, relationName: string, dto: Entity, filter: Filter): Promise; /** * Find a relation for an array of Entities. This will return a Map where the key is the Entity and the value is to * relation or undefined if not found. * @param RelationClass - the class of the relation * @param relationName - the name of the relation to load. * @param dtos - the dtos to find the relation for. * @param opts - Additional options */ findRelation(RelationClass: Class, relationName: string, dtos: Entity[], opts?: FindRelationOptions): Promise>; /** * Finds a single relation. * @param RelationClass - The class to serialize the relation into. * @param dto - The dto to find the relation for. * @param relationName - The name of the relation to query for. * @param opts - Additional options */ findRelation(RelationClass: Class, relationName: string, dto: Entity, opts?: FindRelationOptions): Promise; /** * Add a single relation. * @param id - The id of the entity to add the relation to. * @param relationName - The name of the relation to query for. * @param relationIds - The ids of relations to add. * @param opts - Addition options */ addRelations(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions): Promise; /** * Set the relations on the entity. * * @param id - The id of the entity to set the relation on. * @param relationName - The name of the relation to query for. * @param relationIds - The ids of the relation to set on the entity. If the relationIds is empty all relations * will be removed. * @param opts - Additional options */ setRelations(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions): Promise; /** * Set the relation on the entity. * * @param id - The id of the entity to set the relation on. * @param relationName - The name of the relation to query for. * @param relationId - The id of the relation to set on the entity. * @param opts - Additional options */ setRelation(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions): Promise; /** * Removes multiple relations. * @param id - The id of the entity to add the relation to. * @param relationName - The name of the relation to query for. * @param relationIds - The ids of the relations to add. * @param opts - Additional options */ removeRelations(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions): Promise; /** * Remove the relation on the entity. * * @param id - The id of the entity to set the relation on. * @param relationName - The name of the relation to query for. * @param relationId - The id of the relation to set on the entity. */ removeRelation(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions): Promise; getRelationQueryBuilder(name: string): RelationQueryBuilder; /** * Query for an array of relations for multiple dtos. * @param RelationClass - The class to serialize the relations into. * @param entities - The entities to query relations for. * @param relationName - The name of relation to query for. * @param query - A query to filter, page or sort relations. */ private batchQueryRelations; /** * Query for an array of relations for multiple dtos. * @param RelationClass - The class to serialize the relations into. * @param entities - The entities to query relations for. * @param relationName - The name of relation to query for. * @param query - A query to filter, page or sort relations. */ private batchAggregateRelations; /** * Count the number of relations for multiple dtos. * @param RelationClass - The class to serialize the relations into. * @param entities - The entities to query relations for. * @param relationName - The name of relation to query for. * @param filter - The filter to apply to the relation query. */ private batchCountRelations; /** * Query for a relation for multiple dtos. * @param RelationClass - The class to serialize the relations into. * @param dtos - The dto to query relations for. * @param relationName - The name of relation to query for. * @param query - A query to filter, page or sort relations. */ private batchFindRelations; private createTypeormRelationQueryBuilder; private getRelationMeta; private getRelationEntity; private getRelationsFromPrimaryKeys; private getRelations; private foundAllRelations; }