import { Connection } from "../connection/Connection"; import { FindManyOptions } from "../find-options/FindManyOptions"; import { ObjectType } from "../common/ObjectType"; import { BaseEntityManager } from "./BaseEntityManager"; import { QueryRunnerProvider } from "../query-runner/QueryRunnerProvider"; import { FindOneOptions } from "../find-options/FindOneOptions"; import { DeepPartial } from "../common/DeepPartial"; import { RemoveOptions } from "../repository/RemoveOptions"; import { PersistOptions } from "../repository/PersistOptions"; /** * Entity manager supposed to work with any entity, automatically find its repository and call its methods, * whatever entity type are you passing. */ export declare class EntityManager extends BaseEntityManager { /** * Stores temporarily user data. * Useful for sharing data with subscribers. */ private data; constructor(connection: Connection, queryRunnerProvider?: QueryRunnerProvider); /** * Gets user data by a given key. */ getData(key: string): any; /** * Sets value for the given key in user data. */ setData(key: string, value: any): void; /** * Persists (saves) all given entities in the database. * If entities do not exist in the database then inserts, otherwise updates. */ persist(entity: Entity, options?: PersistOptions): Promise; /** * Persists (saves) all given entities in the database. * If entities do not exist in the database then inserts, otherwise updates. */ persist(targetOrEntity: Function, entity: Entity, options?: PersistOptions): Promise; /** * Persists (saves) all given entities in the database. * If entities do not exist in the database then inserts, otherwise updates. */ persist(targetOrEntity: string, entity: Entity, options?: PersistOptions): Promise; /** * Persists (saves) all given entities in the database. * If entities do not exist in the database then inserts, otherwise updates. */ persist(entities: Entity[], options?: PersistOptions): Promise; /** * Persists (saves) all given entities in the database. * If entities do not exist in the database then inserts, otherwise updates. */ persist(targetOrEntity: Function, entities: Entity[], options?: PersistOptions): Promise; /** * Persists (saves) all given entities in the database. * If entities do not exist in the database then inserts, otherwise updates. */ persist(targetOrEntity: string, entities: Entity[], options?: PersistOptions): Promise; /** * Updates entity partially. Entity can be found by a given conditions. */ update(target: Function | string, conditions: Partial, partialEntity: DeepPartial, options?: PersistOptions): Promise; /** * Updates entity partially. Entity can be found by a given find options. */ update(target: Function | string, findOptions: FindOneOptions, partialEntity: DeepPartial, options?: PersistOptions): Promise; /** * Updates entity partially. Entity will be found by a given id. */ updateById(target: Function | string, id: any, partialEntity: DeepPartial, options?: PersistOptions): Promise; /** * Removes a given entity from the database. */ remove(entity: Entity): Promise; /** * Removes a given entity from the database. */ remove(targetOrEntity: Function, entity: Entity, options?: RemoveOptions): Promise; /** * Removes a given entity from the database. */ remove(targetOrEntity: string, entity: Entity, options?: RemoveOptions): Promise; /** * Removes a given entity from the database. */ remove(entity: Entity[], options?: RemoveOptions): Promise; /** * Removes a given entity from the database. */ remove(targetOrEntity: Function, entity: Entity[], options?: RemoveOptions): Promise; /** * Removes a given entity from the database. */ remove(targetOrEntity: string, entity: Entity[], options?: RemoveOptions): Promise; /** * Removes entity by a given entity id. */ removeById(targetOrEntity: Function | string, id: any, options?: RemoveOptions): Promise; /** * Counts entities that match given options. */ count(entityClass: ObjectType, options?: FindManyOptions): Promise; /** * Counts entities that match given conditions. */ count(entityClass: ObjectType, conditions?: Partial): Promise; /** * Finds entities that match given options. */ find(entityClass: ObjectType, options?: FindManyOptions): Promise; /** * Finds entities that match given conditions. */ find(entityClass: ObjectType, conditions?: Partial): Promise; /** * Finds entities that match given find options. * Also counts all entities that match given conditions, * but ignores pagination settings (from and take options). */ findAndCount(entityClass: ObjectType, options?: FindManyOptions): Promise<[Entity[], number]>; /** * Finds entities that match given conditions. * Also counts all entities that match given conditions, * but ignores pagination settings (from and take options). */ findAndCount(entityClass: ObjectType, conditions?: Partial): Promise<[Entity[], number]>; /** * Finds first entity that matches given find options. */ findOne(entityClass: ObjectType, options?: FindOneOptions): Promise; /** * Finds first entity that matches given conditions. */ findOne(entityClass: ObjectType, conditions?: Partial): Promise; /** * Finds entities with ids. * Optionally find options can be applied. */ findByIds(entityClass: ObjectType, ids: any[], options?: FindManyOptions): Promise; /** * Finds entities with ids. * Optionally conditions can be applied. */ findByIds(entityClass: ObjectType, ids: any[], conditions?: Partial): Promise; /** * Finds entity with given id. * Optionally find options can be applied. */ findOneById(entityClass: ObjectType, id: any, options?: FindOneOptions): Promise; /** * Finds entity with given id. * Optionally conditions can be applied. */ findOneById(entityClass: ObjectType, id: any, conditions?: Partial): Promise; /** * Executes raw SQL query and returns raw database results. */ query(query: string, parameters?: any[]): Promise; /** * Wraps given function execution (and all operations made there) in a transaction. * All database operations must be executed using provided entity manager. */ transaction(runInTransaction: (entityManger: EntityManager) => Promise): Promise; /** * Clears all the data from the given table (truncates/drops it). */ clear(entityClass: ObjectType): Promise; }