UNPKG

2.4 kBTypeScriptView Raw
1import { ObjectLiteral } from "../common/ObjectLiteral";
2import { EntityManager } from "../entity-manager/EntityManager";
3import { Repository } from "./Repository";
4import { TreeRepository } from "./TreeRepository";
5import { ObjectType } from "../common/ObjectType";
6import { SelectQueryBuilder } from "../query-builder/SelectQueryBuilder";
7/**
8 * Provides abstract class for custom repositories that do not inherit from original orm Repository.
9 * Contains all most-necessary methods to simplify code in the custom repository.
10 * All methods are protected thus not exposed and it allows to create encapsulated custom repository.
11 *
12 * @experimental
13 */
14export declare class AbstractRepository<Entity extends ObjectLiteral> {
15 /**
16 * Gets entity manager that allows to perform repository operations with any entity.
17 */
18 protected manager: EntityManager;
19 /**
20 * Gets the original ORM repository for the entity that is managed by this repository.
21 * If current repository does not manage any entity, then exception will be thrown.
22 */
23 protected readonly repository: Repository<Entity>;
24 /**
25 * Gets the original ORM tree repository for the entity that is managed by this repository.
26 * If current repository does not manage any entity, then exception will be thrown.
27 */
28 protected readonly treeRepository: TreeRepository<Entity>;
29 /**
30 * Creates a new query builder for the repository's entity that can be used to build a sql query.
31 * If current repository does not manage any entity, then exception will be thrown.
32 */
33 protected createQueryBuilder(alias: string): SelectQueryBuilder<Entity>;
34 /**
35 * Creates a new query builder for the given entity that can be used to build a sql query.
36 */
37 protected createQueryBuilderFor<T>(entity: ObjectType<T>, alias: string): SelectQueryBuilder<T>;
38 /**
39 * Gets the original ORM repository for the given entity class.
40 */
41 protected getRepositoryFor<T>(entity: ObjectType<T>): Repository<T>;
42 /**
43 * Gets the original ORM tree repository for the given entity class.
44 */
45 protected getTreeRepositoryFor<T>(entity: ObjectType<T>): TreeRepository<T>;
46 /**
47 * Gets custom repository's managed entity.
48 * If given custom repository does not manage any entity then undefined will be returned.
49 */
50 private getCustomRepositoryTarget;
51}