import { Connection } from "../connection/Connection"; import { QueryBuilder } from "../query-builder/QueryBuilder"; import { Repository } from "../repository/Repository"; import { ObjectType } from "../common/ObjectType"; import { TreeRepository } from "../repository/TreeRepository"; import { ObjectLiteral } from "../common/ObjectLiteral"; import { QueryRunnerProvider } from "../query-runner/QueryRunnerProvider"; import { RepositoryAggregator } from "../repository/RepositoryAggregator"; import { SpecificRepository } from "../repository/SpecificRepository"; /** * Common functions shared between different entity manager types. */ export declare abstract class BaseEntityManager { protected connection: Connection; protected queryRunnerProvider: QueryRunnerProvider | undefined; /** * Stores all registered repositories. * Used when custom queryRunnerProvider is provided. */ private readonly repositoryAggregators; /** * @param connection Connection to be used in this entity manager * @param queryRunnerProvider Custom query runner to be used for operations in this entity manager */ constructor(connection: Connection, queryRunnerProvider?: QueryRunnerProvider | undefined); /** * Gets repository for the given entity class. * If single database connection mode is used, then repository is obtained from the * repository aggregator, where each repository is individually created for this entity manager. * When single database connection is not used, repository is being obtained from the connection. */ getRepository(entityClass: ObjectType): Repository; /** * Gets repository for the given entity name. * If single database connection mode is used, then repository is obtained from the * repository aggregator, where each repository is individually created for this entity manager. * When single database connection is not used, repository is being obtained from the connection. */ getRepository(entityName: string): Repository; /** * Gets tree repository for the given entity class. * If single database connection mode is used, then repository is obtained from the * repository aggregator, where each repository is individually created for this entity manager. * When single database connection is not used, repository is being obtained from the connection. */ getTreeRepository(entityClass: ObjectType): TreeRepository; /** * Gets tree repository for the given entity name. * If single database connection mode is used, then repository is obtained from the * repository aggregator, where each repository is individually created for this entity manager. * When single database connection is not used, repository is being obtained from the connection. */ getTreeRepository(entityName: string): TreeRepository; /** * Gets specific repository for the given entity class. * If single database connection mode is used, then repository is obtained from the * repository aggregator, where each repository is individually created for this entity manager. * When single database connection is not used, repository is being obtained from the connection. */ getSpecificRepository(entityClass: ObjectType): SpecificRepository; /** * Gets specific repository for the given entity name. * If single database connection mode is used, then repository is obtained from the * repository aggregator, where each repository is individually created for this entity manager. * When single database connection is not used, repository is being obtained from the connection. */ getSpecificRepository(entityName: string): SpecificRepository; /** * Checks if entity has an id. */ hasId(entity: Object): boolean; /** * Checks if entity of given schema name has an id. */ hasId(target: string, entity: Object): boolean; /** * Creates a new query builder that can be used to build an sql query. */ createQueryBuilder(entityClass: ObjectType, alias: string): QueryBuilder; /** * Creates a new entity instance. */ create(entityClass: ObjectType): Entity; /** * Creates a new entity instance and copies all entity properties from this object into a new entity. * Note that it copies only properties that present in entity schema. */ create(entityClass: ObjectType, plainObject: Object): Entity; /** * Creates a new entities and copies all entity properties from given objects into their new entities. * Note that it copies only properties that present in entity schema. */ create(entityClass: ObjectType, plainObjects: Object[]): Entity[]; /** * Creates a new entity from the given plan javascript object. If entity already exist in the database, then * it loads it (and everything related to it), replaces all values with the new ones from the given object * and returns this new entity. This new entity is actually a loaded from the db entity with all properties * replaced from the new object. */ preload(entityClass: ObjectType, object: Object): Promise; /** * Merges two entities into one new entity. */ merge(entityClass: ObjectType, ...objects: ObjectLiteral[]): Entity; /** * Releases all resources used by entity manager. * This is used when entity manager is created with a single query runner, * and this single query runner needs to be released after job with entity manager is done. */ release(): Promise; /** * Gets, or if does not exist yet, creates and returns a repository aggregator for a particular entity target. */ protected obtainRepositoryAggregator(entityClassOrName: ObjectType | string): RepositoryAggregator; }