typeorm 0.3.7-dev.60a7960 → 0.3.7-dev.97e1dc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/data-source/DataSource.d.ts +4 -3
- package/browser/data-source/DataSource.js.map +1 -1
- package/browser/entity-manager/EntityManager.d.ts +9 -8
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/entity-manager/MongoEntityManager.d.ts +1 -1
- package/browser/entity-manager/MongoEntityManager.js.map +1 -1
- package/browser/globals.d.ts +5 -4
- package/browser/globals.js.map +1 -1
- package/browser/query-builder/RelationIdLoader.d.ts +1 -1
- package/browser/query-builder/RelationIdLoader.js.map +1 -1
- package/browser/query-builder/SoftDeleteQueryBuilder.d.ts +2 -2
- package/browser/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/browser/query-builder/UpdateQueryBuilder.d.ts +1 -1
- package/browser/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/browser/query-builder/transformer/DocumentToEntityTransformer.js +1 -1
- package/browser/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
- package/browser/query-builder/transformer/PlainObjectToNewEntityTransformer.d.ts +1 -1
- package/browser/query-builder/transformer/PlainObjectToNewEntityTransformer.js.map +1 -1
- package/browser/repository/AbstractRepository.d.ts +3 -3
- package/browser/repository/AbstractRepository.js.map +1 -1
- package/browser/repository/TreeRepository.d.ts +2 -1
- package/browser/repository/TreeRepository.js.map +1 -1
- package/data-source/DataSource.d.ts +4 -3
- package/data-source/DataSource.js.map +1 -1
- package/entity-manager/EntityManager.d.ts +9 -8
- package/entity-manager/EntityManager.js.map +1 -1
- package/entity-manager/MongoEntityManager.d.ts +1 -1
- package/entity-manager/MongoEntityManager.js.map +1 -1
- package/globals.d.ts +5 -4
- package/globals.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/RelationIdLoader.d.ts +1 -1
- package/query-builder/RelationIdLoader.js.map +1 -1
- package/query-builder/SoftDeleteQueryBuilder.d.ts +2 -2
- package/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/query-builder/UpdateQueryBuilder.d.ts +1 -1
- package/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/query-builder/transformer/DocumentToEntityTransformer.js +1 -1
- package/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
- package/query-builder/transformer/PlainObjectToNewEntityTransformer.d.ts +1 -1
- package/query-builder/transformer/PlainObjectToNewEntityTransformer.js.map +1 -1
- package/repository/AbstractRepository.d.ts +3 -3
- package/repository/AbstractRepository.js.map +1 -1
- package/repository/TreeRepository.d.ts +2 -1
- package/repository/TreeRepository.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data-source/DataSource.ts"],"names":[],"mappings":";;;AAMA,oFAAgF;AAChF,oCAKiB;AAMjB,sEAAkE;AAIlE,yFAAqF;AAErF,iFAA6E;AAC7E,2DAAuD;AACvD,uFAAmF;AAEnF,4EAAwE;AACxE,2DAAuD;AACvD,8EAA0E;AAG1E,oEAAgE;AAChE,qDAAiD;AAGjD,oCAAuC;AACvC,wEAAoE;AACpE,uDAAmD;AACnD,6DAAyD;AAEzD;;;;;;;GAOG;AACH,MAAa,UAAU;IA4EnB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,OAA0B;QA/E7B,mBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAgDjD;;WAEG;QACM,eAAU,GAAyB,EAAE,CAAA;QAE9C;;WAEG;QACM,gBAAW,GAAqC,EAAE,CAAA;QAE3D;;WAEG;QACM,oBAAe,GAAqB,EAAE,CAAA;QAmB3C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,CAAA;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,6BAAa,EAAE,CAAC,MAAM,CACpC,IAAI,CAAC,OAAO,CAAC,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AE,eAAe,EAAE,eAAe,EAAE,CAAC,CAAA;QAE9D,6BAA6B;QAC7B,MAAM,mBAAmB,GAAG,yBAAW,CAAC,gBAAgB,CACpD,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAChC,CAAA;QACD,MAAM,UAAU,GAAG,MAAM,yBAAyB,CAAC,eAAe,CAC9D,mBAAmB,CACtB,CAAA;QACD,yBAAW,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAA;QAEpD,iGAAiG;QACjG,uBAAuB,CAAC,YAAY,CAChC,IAAI,CAAC,eAAe,CAAC,MAAM,CACvB,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,KAAK,MAAM,CAC9C,EACD,IAAI,CAAC,MAAM,CACd,CAAA;QAED,0CAA0C;QAC1C,KAAK,IAAI,cAAc,IAAI,eAAe,EAAE;YACxC,IACI,iCAAe,CAAC,uBAAuB,CAAC,cAAc,CAAC,MAAM,CAAC,EAChE;gBACE,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;aAC5C;SACJ;IACL,CAAC;CACJ;AAvoBD,gCAuoBC","file":"DataSource.js","sourcesContent":["import { Driver } from \"../driver/Driver\"\nimport { Repository } from \"../repository/Repository\"\nimport { EntitySubscriberInterface } from \"../subscriber/EntitySubscriberInterface\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { ObjectType } from \"../common/ObjectType\"\nimport { EntityManager } from \"../entity-manager/EntityManager\"\nimport { DefaultNamingStrategy } from \"../naming-strategy/DefaultNamingStrategy\"\nimport {\n CannotConnectAlreadyConnectedError,\n CannotExecuteNotConnectedError,\n EntityMetadataNotFoundError,\n QueryRunnerProviderAlreadyReleasedError,\n} from \"../error\"\nimport { TreeRepository } from \"../repository/TreeRepository\"\nimport { NamingStrategyInterface } from \"../naming-strategy/NamingStrategyInterface\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { Logger } from \"../logger/Logger\"\nimport { MigrationInterface } from \"../migration/MigrationInterface\"\nimport { MigrationExecutor } from \"../migration/MigrationExecutor\"\nimport { Migration } from \"../migration/Migration\"\nimport { MongoRepository } from \"../repository/MongoRepository\"\nimport { MongoEntityManager } from \"../entity-manager/MongoEntityManager\"\nimport { EntityMetadataValidator } from \"../metadata-builder/EntityMetadataValidator\"\nimport { DataSourceOptions } from \"./DataSourceOptions\"\nimport { EntityManagerFactory } from \"../entity-manager/EntityManagerFactory\"\nimport { DriverFactory } from \"../driver/DriverFactory\"\nimport { ConnectionMetadataBuilder } from \"../connection/ConnectionMetadataBuilder\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { LoggerFactory } from \"../logger/LoggerFactory\"\nimport { QueryResultCacheFactory } from \"../cache/QueryResultCacheFactory\"\nimport { QueryResultCache } from \"../cache/QueryResultCache\"\nimport { SqljsEntityManager } from \"../entity-manager/SqljsEntityManager\"\nimport { RelationLoader } from \"../query-builder/RelationLoader\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { IsolationLevel } from \"../driver/types/IsolationLevel\"\nimport { ReplicationMode } from \"../driver/types/ReplicationMode\"\nimport { TypeORMError } from \"../error\"\nimport { RelationIdLoader } from \"../query-builder/RelationIdLoader\"\nimport { DriverUtils } from \"../driver/DriverUtils\"\nimport { InstanceChecker } from \"../util/InstanceChecker\"\n\n/**\n * DataSource is a pre-defined connection configuration to a specific database.\n * You can have multiple data sources connected (with multiple connections in it),\n * connected to multiple databases in your application.\n *\n * Before, it was called `Connection`, but now `Connection` is deprecated\n * because `Connection` isn't the best name for what it's actually is.\n */\nexport class DataSource {\n readonly \"@instanceof\" = Symbol.for(\"DataSource\")\n\n // -------------------------------------------------------------------------\n // Public Readonly Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection name.\n *\n * @deprecated we don't need names anymore since we are going to drop all related methods relying on this property.\n */\n readonly name: string\n\n /**\n * Connection options.\n */\n readonly options: DataSourceOptions\n\n /**\n * Indicates if DataSource is initialized or not.\n */\n readonly isInitialized: boolean\n\n /**\n * Database driver used by this connection.\n */\n driver: Driver\n\n /**\n * EntityManager of this connection.\n */\n readonly manager: EntityManager\n\n /**\n * Naming strategy used in the connection.\n */\n namingStrategy: NamingStrategyInterface\n\n /**\n * Name for the metadata table\n */\n readonly metadataTableName: string\n\n /**\n * Logger used to log orm events.\n */\n logger: Logger\n\n /**\n * Migration instances that are registered for this connection.\n */\n readonly migrations: MigrationInterface[] = []\n\n /**\n * Entity subscriber instances that are registered for this connection.\n */\n readonly subscribers: EntitySubscriberInterface<any>[] = []\n\n /**\n * All entity metadatas that are registered for this connection.\n */\n readonly entityMetadatas: EntityMetadata[] = []\n\n /**\n * Used to work with query result cache.\n */\n queryResultCache?: QueryResultCache\n\n /**\n * Used to load relations and work with lazy relations.\n */\n readonly relationLoader: RelationLoader\n\n readonly relationIdLoader: RelationIdLoader\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options: DataSourceOptions) {\n this.name = options.name || \"default\"\n this.options = options\n this.logger = new LoggerFactory().create(\n this.options.logger,\n this.options.logging,\n )\n this.driver = new DriverFactory().create(this)\n this.manager = this.createEntityManager()\n this.namingStrategy =\n options.namingStrategy || new DefaultNamingStrategy()\n this.metadataTableName = options.metadataTableName || \"typeorm_metadata\"\n this.queryResultCache = options.cache\n ? new QueryResultCacheFactory(this).create()\n : undefined\n this.relationLoader = new RelationLoader(this)\n this.relationIdLoader = new RelationIdLoader(this)\n this.isInitialized = false\n }\n\n // -------------------------------------------------------------------------\n // Public Accessors\n // -------------------------------------------------------------------------\n\n /**\n Indicates if DataSource is initialized or not.\n *\n * @deprecated use .isInitialized instead\n */\n get isConnected() {\n return this.isInitialized\n }\n\n /**\n * Gets the mongodb entity manager that allows to perform mongodb-specific repository operations\n * with any entity in this connection.\n *\n * Available only in mongodb connections.\n */\n get mongoManager(): MongoEntityManager {\n if (!InstanceChecker.isMongoEntityManager(this.manager))\n throw new TypeORMError(\n `MongoEntityManager is only available for MongoDB databases.`,\n )\n\n return this.manager as MongoEntityManager\n }\n\n /**\n * Gets a sql.js specific Entity Manager that allows to perform special load and save operations\n *\n * Available only in connection with the sqljs driver.\n */\n get sqljsManager(): SqljsEntityManager {\n if (!InstanceChecker.isSqljsEntityManager(this.manager))\n throw new TypeORMError(\n `SqljsEntityManager is only available for Sqljs databases.`,\n )\n\n return this.manager\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n /**\n * Updates current connection options with provided options.\n */\n setOptions(options: Partial<DataSourceOptions>): this {\n Object.assign(this.options, options)\n\n if (options.logger || options.logging) {\n this.logger = new LoggerFactory().create(\n options.logger || this.options.logger,\n options.logging || this.options.logging,\n )\n }\n\n if (options.namingStrategy) {\n this.namingStrategy = options.namingStrategy\n }\n\n if (options.cache) {\n this.queryResultCache = new QueryResultCacheFactory(this).create()\n }\n\n return this\n }\n\n /**\n * Performs connection to the database.\n * This method should be called once on application bootstrap.\n * This method not necessarily creates database connection (depend on database type),\n * but it also can setup a connection pool with database to use.\n */\n async initialize(): Promise<this> {\n if (this.isInitialized)\n throw new CannotConnectAlreadyConnectedError(this.name)\n\n // connect to the database via its driver\n await this.driver.connect()\n\n // connect to the cache-specific database if cache is enabled\n if (this.queryResultCache) await this.queryResultCache.connect()\n\n // set connected status for the current connection\n ObjectUtils.assign(this, { isInitialized: true })\n\n try {\n // build all metadatas registered in the current connection\n await this.buildMetadatas()\n\n await this.driver.afterConnect()\n\n // if option is set - drop schema once connection is done\n if (this.options.dropSchema) await this.dropDatabase()\n\n // if option is set - automatically synchronize a schema\n if (this.options.migrationsRun)\n await this.runMigrations({\n transaction: this.options.migrationsTransactionMode,\n })\n\n // if option is set - automatically synchronize a schema\n if (this.options.synchronize) await this.synchronize()\n } catch (error) {\n // if for some reason build metadata fail (for example validation error during entity metadata check)\n // connection needs to be closed\n await this.close()\n throw error\n }\n\n return this\n }\n\n /**\n * Performs connection to the database.\n * This method should be called once on application bootstrap.\n * This method not necessarily creates database connection (depend on database type),\n * but it also can setup a connection pool with database to use.\n *\n * @deprecated use .initialize method instead\n */\n async connect(): Promise<this> {\n return this.initialize()\n }\n\n /**\n * Closes connection with the database.\n * Once connection is closed, you cannot use repositories or perform any operations except opening connection again.\n */\n async destroy(): Promise<void> {\n if (!this.isInitialized)\n throw new CannotExecuteNotConnectedError(this.name)\n\n await this.driver.disconnect()\n\n // disconnect from the cache-specific database if cache was enabled\n if (this.queryResultCache) await this.queryResultCache.disconnect()\n\n ObjectUtils.assign(this, { isInitialized: false })\n }\n\n /**\n * Closes connection with the database.\n * Once connection is closed, you cannot use repositories or perform any operations except opening connection again.\n *\n * @deprecated use .destroy method instead\n */\n async close(): Promise<void> {\n return this.destroy()\n }\n\n /**\n * Creates database schema for all entities registered in this connection.\n * Can be used only after connection to the database is established.\n *\n * @param dropBeforeSync If set to true then it drops the database with all its tables and data\n */\n async synchronize(dropBeforeSync: boolean = false): Promise<void> {\n if (!this.isInitialized)\n throw new CannotExecuteNotConnectedError(this.name)\n\n if (dropBeforeSync) await this.dropDatabase()\n\n const schemaBuilder = this.driver.createSchemaBuilder()\n await schemaBuilder.build()\n }\n\n /**\n * Drops the database and all its data.\n * Be careful with this method on production since this method will erase all your database tables and their data.\n * Can be used only after connection to the database is established.\n */\n // TODO rename\n async dropDatabase(): Promise<void> {\n const queryRunner = this.createQueryRunner()\n try {\n if (\n this.driver.options.type === \"mssql\" ||\n DriverUtils.isMySQLFamily(this.driver) ||\n this.driver.options.type === \"aurora-mysql\" ||\n DriverUtils.isSQLiteFamily(this.driver)\n ) {\n const databases: string[] = []\n this.entityMetadatas.forEach((metadata) => {\n if (\n metadata.database &&\n databases.indexOf(metadata.database) === -1\n )\n databases.push(metadata.database)\n })\n if (databases.length === 0 && this.driver.database) {\n databases.push(this.driver.database)\n }\n\n if (databases.length === 0) {\n await queryRunner.clearDatabase()\n } else {\n for (const database of databases) {\n await queryRunner.clearDatabase(database)\n }\n }\n } else {\n await queryRunner.clearDatabase()\n }\n } finally {\n await queryRunner.release()\n }\n }\n\n /**\n * Runs all pending migrations.\n * Can be used only after connection to the database is established.\n */\n async runMigrations(options?: {\n transaction?: \"all\" | \"none\" | \"each\"\n }): Promise<Migration[]> {\n if (!this.isInitialized)\n throw new CannotExecuteNotConnectedError(this.name)\n\n const migrationExecutor = new MigrationExecutor(this)\n migrationExecutor.transaction =\n (options && options.transaction) || \"all\"\n\n const successMigrations =\n await migrationExecutor.executePendingMigrations()\n return successMigrations\n }\n\n /**\n * Reverts last executed migration.\n * Can be used only after connection to the database is established.\n */\n async undoLastMigration(options?: {\n transaction?: \"all\" | \"none\" | \"each\"\n }): Promise<void> {\n if (!this.isInitialized)\n throw new CannotExecuteNotConnectedError(this.name)\n\n const migrationExecutor = new MigrationExecutor(this)\n migrationExecutor.transaction =\n (options && options.transaction) || \"all\"\n\n await migrationExecutor.undoLastMigration()\n }\n\n /**\n * Lists all migrations and whether they have been run.\n * Returns true if there are pending migrations\n */\n async showMigrations(): Promise<boolean> {\n if (!this.isInitialized) {\n throw new CannotExecuteNotConnectedError(this.name)\n }\n const migrationExecutor = new MigrationExecutor(this)\n return await migrationExecutor.showMigrations()\n }\n\n /**\n * Checks if entity metadata exist for the given entity class, target name or table name.\n */\n hasMetadata(target: EntityTarget<any>): boolean {\n return !!this.findMetadata(target)\n }\n\n /**\n * Gets entity metadata for the given entity class or schema name.\n */\n getMetadata(target: EntityTarget<any>): EntityMetadata {\n const metadata = this.findMetadata(target)\n if (!metadata) throw new EntityMetadataNotFoundError(target)\n\n return metadata\n }\n\n /**\n * Gets repository for the given entity.\n */\n getRepository<Entity>(target: EntityTarget<Entity>): Repository<Entity> {\n return this.manager.getRepository(target)\n }\n\n /**\n * Gets tree repository for the given entity class or name.\n * Only tree-type entities can have a TreeRepository, like ones decorated with @Tree decorator.\n */\n getTreeRepository<Entity>(\n target: EntityTarget<Entity>,\n ): TreeRepository<Entity> {\n return this.manager.getTreeRepository(target)\n }\n\n /**\n * Gets mongodb-specific repository for the given entity class or name.\n * Works only if connection is mongodb-specific.\n */\n getMongoRepository<Entity>(\n target: EntityTarget<Entity>,\n ): MongoRepository<Entity> {\n if (!(this.driver.options.type === \"mongodb\"))\n throw new TypeORMError(\n `You can use getMongoRepository only for MongoDB connections.`,\n )\n\n return this.manager.getRepository(target) as any\n }\n\n /**\n * Gets custom entity repository marked with @EntityRepository decorator.\n *\n * @deprecated use Repository.extend function to create a custom repository\n */\n getCustomRepository<T>(customRepository: ObjectType<T>): T {\n return this.manager.getCustomRepository(customRepository)\n }\n\n /**\n * Wraps given function execution (and all operations made there) into a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n async transaction<T>(\n isolationLevel: IsolationLevel,\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n async transaction<T>(\n isolationOrRunInTransaction:\n | IsolationLevel\n | ((entityManager: EntityManager) => Promise<T>),\n runInTransactionParam?: (entityManager: EntityManager) => Promise<T>,\n ): Promise<any> {\n return this.manager.transaction(\n isolationOrRunInTransaction as any,\n runInTransactionParam as any,\n )\n }\n\n /**\n * Executes raw SQL query and returns raw database results.\n */\n async query(\n query: string,\n parameters?: any[],\n queryRunner?: QueryRunner,\n ): Promise<any> {\n if (InstanceChecker.isMongoEntityManager(this.manager))\n throw new TypeORMError(`Queries aren't supported by MongoDB.`)\n\n if (queryRunner && queryRunner.isReleased)\n throw new QueryRunnerProviderAlreadyReleasedError()\n\n const usedQueryRunner = queryRunner || this.createQueryRunner()\n\n try {\n return await usedQueryRunner.query(query, parameters) // await is needed here because we are using finally\n } finally {\n if (!queryRunner) await usedQueryRunner.release()\n }\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass: EntityTarget<Entity>,\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityOrRunner?: EntityTarget<Entity> | QueryRunner,\n alias?: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n if (InstanceChecker.isMongoEntityManager(this.manager))\n throw new TypeORMError(`Query Builder is not supported by MongoDB.`)\n\n if (alias) {\n alias = DriverUtils.buildAlias(this.driver, alias)\n const metadata = this.getMetadata(\n entityOrRunner as EntityTarget<Entity>,\n )\n return new SelectQueryBuilder(this, queryRunner)\n .select(alias)\n .from(metadata.target, alias)\n } else {\n return new SelectQueryBuilder(\n this,\n entityOrRunner as QueryRunner | undefined,\n )\n }\n }\n\n /**\n * Creates a query runner used for perform queries on a single database connection.\n * Using query runners you can control your queries to execute using single database connection and\n * manually control your database transaction.\n *\n * Mode is used in replication mode and indicates whatever you want to connect\n * to master database or any of slave databases.\n * If you perform writes you must use master database,\n * if you perform reads you can use slave databases.\n */\n createQueryRunner(mode: ReplicationMode = \"master\"): QueryRunner {\n const queryRunner = this.driver.createQueryRunner(mode)\n const manager = this.createEntityManager(queryRunner)\n Object.assign(queryRunner, { manager: manager })\n return queryRunner\n }\n\n /**\n * Gets entity metadata of the junction table (many-to-many table).\n */\n getManyToManyMetadata(\n entityTarget: EntityTarget<any>,\n relationPropertyPath: string,\n ) {\n const relationMetadata =\n this.getMetadata(entityTarget).findRelationWithPropertyPath(\n relationPropertyPath,\n )\n if (!relationMetadata)\n throw new TypeORMError(\n `Relation \"${relationPropertyPath}\" was not found in ${entityTarget} entity.`,\n )\n if (!relationMetadata.isManyToMany)\n throw new TypeORMError(\n `Relation \"${entityTarget}#${relationPropertyPath}\" does not have a many-to-many relationship.` +\n `You can use this method only on many-to-many relations.`,\n )\n\n return relationMetadata.junctionEntityMetadata\n }\n\n /**\n * Creates an Entity Manager for the current connection with the help of the EntityManagerFactory.\n */\n createEntityManager(queryRunner?: QueryRunner): EntityManager {\n return new EntityManagerFactory().create(this, queryRunner)\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Finds exist entity metadata by the given entity class, target name or table name.\n */\n protected findMetadata(\n target: EntityTarget<any>,\n ): EntityMetadata | undefined {\n return this.entityMetadatas.find((metadata) => {\n if (metadata.target === target) return true\n if (InstanceChecker.isEntitySchema(target)) {\n return metadata.name === target.options.name\n }\n if (typeof target === \"string\") {\n if (target.indexOf(\".\") !== -1) {\n return metadata.tablePath === target\n } else {\n return (\n metadata.name === target ||\n metadata.tableName === target\n )\n }\n }\n if (\n ObjectUtils.isObject(target) &&\n typeof target.name === \"string\"\n ) {\n if (target.name.indexOf(\".\") !== -1) {\n return metadata.tablePath === target.name\n } else {\n return (\n metadata.name === target.name ||\n metadata.tableName === target.name\n )\n }\n }\n\n return false\n })\n }\n\n /**\n * Builds metadatas for all registered classes inside this connection.\n */\n protected async buildMetadatas(): Promise<void> {\n const connectionMetadataBuilder = new ConnectionMetadataBuilder(this)\n const entityMetadataValidator = new EntityMetadataValidator()\n\n // create subscribers instances if they are not disallowed from high-level (for example they can disallowed from migrations run process)\n const flattenedSubscribers = ObjectUtils.mixedListToArray(\n this.options.subscribers || [],\n )\n const subscribers = await connectionMetadataBuilder.buildSubscribers(\n flattenedSubscribers,\n )\n ObjectUtils.assign(this, { subscribers: subscribers })\n\n // build entity metadatas\n const flattenedEntities = ObjectUtils.mixedListToArray(\n this.options.entities || [],\n )\n const entityMetadatas =\n await connectionMetadataBuilder.buildEntityMetadatas(\n flattenedEntities,\n )\n ObjectUtils.assign(this, { entityMetadatas: entityMetadatas })\n\n // create migration instances\n const flattenedMigrations = ObjectUtils.mixedListToArray(\n this.options.migrations || [],\n )\n const migrations = await connectionMetadataBuilder.buildMigrations(\n flattenedMigrations,\n )\n ObjectUtils.assign(this, { migrations: migrations })\n\n // validate all created entity metadatas to make sure user created entities are valid and correct\n entityMetadataValidator.validateMany(\n this.entityMetadatas.filter(\n (metadata) => metadata.tableType !== \"view\",\n ),\n this.driver,\n )\n\n // set current data source to the entities\n for (let entityMetadata of entityMetadatas) {\n if (\n InstanceChecker.isBaseEntityConstructor(entityMetadata.target)\n ) {\n entityMetadata.target.useDataSource(this)\n }\n }\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/data-source/DataSource.ts"],"names":[],"mappings":";;;AAMA,oFAAgF;AAChF,oCAKiB;AAMjB,sEAAkE;AAIlE,yFAAqF;AAErF,iFAA6E;AAC7E,2DAAuD;AACvD,uFAAmF;AAEnF,4EAAwE;AACxE,2DAAuD;AACvD,8EAA0E;AAG1E,oEAAgE;AAChE,qDAAiD;AAGjD,oCAAuC;AACvC,wEAAoE;AACpE,uDAAmD;AACnD,6DAAyD;AAGzD;;;;;;;GAOG;AACH,MAAa,UAAU;IA4EnB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,OAA0B;QA/E7B,mBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAgDjD;;WAEG;QACM,eAAU,GAAyB,EAAE,CAAA;QAE9C;;WAEG;QACM,gBAAW,GAAqC,EAAE,CAAA;QAE3D;;WAEG;QACM,oBAAe,GAAqB,EAAE,CAAA;QAmB3C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,CAAA;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,6BAAa,EAAE,CAAC,MAAM,CACpC,IAAI,CAAC,OAAO,CAAC,MAAM,EACnB,IAAI,CAAC,OAAO,CAAC,OAAO,CACvB,CAAA;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,6BAAa,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QA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AAI,EAAE,CAChC,CAAA;QACD,MAAM,UAAU,GAAG,MAAM,yBAAyB,CAAC,eAAe,CAC9D,mBAAmB,CACtB,CAAA;QACD,yBAAW,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAA;QAEpD,iGAAiG;QACjG,uBAAuB,CAAC,YAAY,CAChC,IAAI,CAAC,eAAe,CAAC,MAAM,CACvB,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,KAAK,MAAM,CAC9C,EACD,IAAI,CAAC,MAAM,CACd,CAAA;QAED,0CAA0C;QAC1C,KAAK,IAAI,cAAc,IAAI,eAAe,EAAE;YACxC,IACI,iCAAe,CAAC,uBAAuB,CAAC,cAAc,CAAC,MAAM,CAAC,EAChE;gBACE,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;aAC5C;SACJ;IACL,CAAC;CACJ;AAzoBD,gCAyoBC","file":"DataSource.js","sourcesContent":["import { Driver } from \"../driver/Driver\"\nimport { Repository } from \"../repository/Repository\"\nimport { EntitySubscriberInterface } from \"../subscriber/EntitySubscriberInterface\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { ObjectType } from \"../common/ObjectType\"\nimport { EntityManager } from \"../entity-manager/EntityManager\"\nimport { DefaultNamingStrategy } from \"../naming-strategy/DefaultNamingStrategy\"\nimport {\n CannotConnectAlreadyConnectedError,\n CannotExecuteNotConnectedError,\n EntityMetadataNotFoundError,\n QueryRunnerProviderAlreadyReleasedError,\n} from \"../error\"\nimport { TreeRepository } from \"../repository/TreeRepository\"\nimport { NamingStrategyInterface } from \"../naming-strategy/NamingStrategyInterface\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { Logger } from \"../logger/Logger\"\nimport { MigrationInterface } from \"../migration/MigrationInterface\"\nimport { MigrationExecutor } from \"../migration/MigrationExecutor\"\nimport { Migration } from \"../migration/Migration\"\nimport { MongoRepository } from \"../repository/MongoRepository\"\nimport { MongoEntityManager } from \"../entity-manager/MongoEntityManager\"\nimport { EntityMetadataValidator } from \"../metadata-builder/EntityMetadataValidator\"\nimport { DataSourceOptions } from \"./DataSourceOptions\"\nimport { EntityManagerFactory } from \"../entity-manager/EntityManagerFactory\"\nimport { DriverFactory } from \"../driver/DriverFactory\"\nimport { ConnectionMetadataBuilder } from \"../connection/ConnectionMetadataBuilder\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { LoggerFactory } from \"../logger/LoggerFactory\"\nimport { QueryResultCacheFactory } from \"../cache/QueryResultCacheFactory\"\nimport { QueryResultCache } from \"../cache/QueryResultCache\"\nimport { SqljsEntityManager } from \"../entity-manager/SqljsEntityManager\"\nimport { RelationLoader } from \"../query-builder/RelationLoader\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { IsolationLevel } from \"../driver/types/IsolationLevel\"\nimport { ReplicationMode } from \"../driver/types/ReplicationMode\"\nimport { TypeORMError } from \"../error\"\nimport { RelationIdLoader } from \"../query-builder/RelationIdLoader\"\nimport { DriverUtils } from \"../driver/DriverUtils\"\nimport { InstanceChecker } from \"../util/InstanceChecker\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\n\n/**\n * DataSource is a pre-defined connection configuration to a specific database.\n * You can have multiple data sources connected (with multiple connections in it),\n * connected to multiple databases in your application.\n *\n * Before, it was called `Connection`, but now `Connection` is deprecated\n * because `Connection` isn't the best name for what it's actually is.\n */\nexport class DataSource {\n readonly \"@instanceof\" = Symbol.for(\"DataSource\")\n\n // -------------------------------------------------------------------------\n // Public Readonly Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection name.\n *\n * @deprecated we don't need names anymore since we are going to drop all related methods relying on this property.\n */\n readonly name: string\n\n /**\n * Connection options.\n */\n readonly options: DataSourceOptions\n\n /**\n * Indicates if DataSource is initialized or not.\n */\n readonly isInitialized: boolean\n\n /**\n * Database driver used by this connection.\n */\n driver: Driver\n\n /**\n * EntityManager of this connection.\n */\n readonly manager: EntityManager\n\n /**\n * Naming strategy used in the connection.\n */\n namingStrategy: NamingStrategyInterface\n\n /**\n * Name for the metadata table\n */\n readonly metadataTableName: string\n\n /**\n * Logger used to log orm events.\n */\n logger: Logger\n\n /**\n * Migration instances that are registered for this connection.\n */\n readonly migrations: MigrationInterface[] = []\n\n /**\n * Entity subscriber instances that are registered for this connection.\n */\n readonly subscribers: EntitySubscriberInterface<any>[] = []\n\n /**\n * All entity metadatas that are registered for this connection.\n */\n readonly entityMetadatas: EntityMetadata[] = []\n\n /**\n * Used to work with query result cache.\n */\n queryResultCache?: QueryResultCache\n\n /**\n * Used to load relations and work with lazy relations.\n */\n readonly relationLoader: RelationLoader\n\n readonly relationIdLoader: RelationIdLoader\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options: DataSourceOptions) {\n this.name = options.name || \"default\"\n this.options = options\n this.logger = new LoggerFactory().create(\n this.options.logger,\n this.options.logging,\n )\n this.driver = new DriverFactory().create(this)\n this.manager = this.createEntityManager()\n this.namingStrategy =\n options.namingStrategy || new DefaultNamingStrategy()\n this.metadataTableName = options.metadataTableName || \"typeorm_metadata\"\n this.queryResultCache = options.cache\n ? new QueryResultCacheFactory(this).create()\n : undefined\n this.relationLoader = new RelationLoader(this)\n this.relationIdLoader = new RelationIdLoader(this)\n this.isInitialized = false\n }\n\n // -------------------------------------------------------------------------\n // Public Accessors\n // -------------------------------------------------------------------------\n\n /**\n Indicates if DataSource is initialized or not.\n *\n * @deprecated use .isInitialized instead\n */\n get isConnected() {\n return this.isInitialized\n }\n\n /**\n * Gets the mongodb entity manager that allows to perform mongodb-specific repository operations\n * with any entity in this connection.\n *\n * Available only in mongodb connections.\n */\n get mongoManager(): MongoEntityManager {\n if (!InstanceChecker.isMongoEntityManager(this.manager))\n throw new TypeORMError(\n `MongoEntityManager is only available for MongoDB databases.`,\n )\n\n return this.manager as MongoEntityManager\n }\n\n /**\n * Gets a sql.js specific Entity Manager that allows to perform special load and save operations\n *\n * Available only in connection with the sqljs driver.\n */\n get sqljsManager(): SqljsEntityManager {\n if (!InstanceChecker.isSqljsEntityManager(this.manager))\n throw new TypeORMError(\n `SqljsEntityManager is only available for Sqljs databases.`,\n )\n\n return this.manager\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n /**\n * Updates current connection options with provided options.\n */\n setOptions(options: Partial<DataSourceOptions>): this {\n Object.assign(this.options, options)\n\n if (options.logger || options.logging) {\n this.logger = new LoggerFactory().create(\n options.logger || this.options.logger,\n options.logging || this.options.logging,\n )\n }\n\n if (options.namingStrategy) {\n this.namingStrategy = options.namingStrategy\n }\n\n if (options.cache) {\n this.queryResultCache = new QueryResultCacheFactory(this).create()\n }\n\n return this\n }\n\n /**\n * Performs connection to the database.\n * This method should be called once on application bootstrap.\n * This method not necessarily creates database connection (depend on database type),\n * but it also can setup a connection pool with database to use.\n */\n async initialize(): Promise<this> {\n if (this.isInitialized)\n throw new CannotConnectAlreadyConnectedError(this.name)\n\n // connect to the database via its driver\n await this.driver.connect()\n\n // connect to the cache-specific database if cache is enabled\n if (this.queryResultCache) await this.queryResultCache.connect()\n\n // set connected status for the current connection\n ObjectUtils.assign(this, { isInitialized: true })\n\n try {\n // build all metadatas registered in the current connection\n await this.buildMetadatas()\n\n await this.driver.afterConnect()\n\n // if option is set - drop schema once connection is done\n if (this.options.dropSchema) await this.dropDatabase()\n\n // if option is set - automatically synchronize a schema\n if (this.options.migrationsRun)\n await this.runMigrations({\n transaction: this.options.migrationsTransactionMode,\n })\n\n // if option is set - automatically synchronize a schema\n if (this.options.synchronize) await this.synchronize()\n } catch (error) {\n // if for some reason build metadata fail (for example validation error during entity metadata check)\n // connection needs to be closed\n await this.close()\n throw error\n }\n\n return this\n }\n\n /**\n * Performs connection to the database.\n * This method should be called once on application bootstrap.\n * This method not necessarily creates database connection (depend on database type),\n * but it also can setup a connection pool with database to use.\n *\n * @deprecated use .initialize method instead\n */\n async connect(): Promise<this> {\n return this.initialize()\n }\n\n /**\n * Closes connection with the database.\n * Once connection is closed, you cannot use repositories or perform any operations except opening connection again.\n */\n async destroy(): Promise<void> {\n if (!this.isInitialized)\n throw new CannotExecuteNotConnectedError(this.name)\n\n await this.driver.disconnect()\n\n // disconnect from the cache-specific database if cache was enabled\n if (this.queryResultCache) await this.queryResultCache.disconnect()\n\n ObjectUtils.assign(this, { isInitialized: false })\n }\n\n /**\n * Closes connection with the database.\n * Once connection is closed, you cannot use repositories or perform any operations except opening connection again.\n *\n * @deprecated use .destroy method instead\n */\n async close(): Promise<void> {\n return this.destroy()\n }\n\n /**\n * Creates database schema for all entities registered in this connection.\n * Can be used only after connection to the database is established.\n *\n * @param dropBeforeSync If set to true then it drops the database with all its tables and data\n */\n async synchronize(dropBeforeSync: boolean = false): Promise<void> {\n if (!this.isInitialized)\n throw new CannotExecuteNotConnectedError(this.name)\n\n if (dropBeforeSync) await this.dropDatabase()\n\n const schemaBuilder = this.driver.createSchemaBuilder()\n await schemaBuilder.build()\n }\n\n /**\n * Drops the database and all its data.\n * Be careful with this method on production since this method will erase all your database tables and their data.\n * Can be used only after connection to the database is established.\n */\n // TODO rename\n async dropDatabase(): Promise<void> {\n const queryRunner = this.createQueryRunner()\n try {\n if (\n this.driver.options.type === \"mssql\" ||\n DriverUtils.isMySQLFamily(this.driver) ||\n this.driver.options.type === \"aurora-mysql\" ||\n DriverUtils.isSQLiteFamily(this.driver)\n ) {\n const databases: string[] = []\n this.entityMetadatas.forEach((metadata) => {\n if (\n metadata.database &&\n databases.indexOf(metadata.database) === -1\n )\n databases.push(metadata.database)\n })\n if (databases.length === 0 && this.driver.database) {\n databases.push(this.driver.database)\n }\n\n if (databases.length === 0) {\n await queryRunner.clearDatabase()\n } else {\n for (const database of databases) {\n await queryRunner.clearDatabase(database)\n }\n }\n } else {\n await queryRunner.clearDatabase()\n }\n } finally {\n await queryRunner.release()\n }\n }\n\n /**\n * Runs all pending migrations.\n * Can be used only after connection to the database is established.\n */\n async runMigrations(options?: {\n transaction?: \"all\" | \"none\" | \"each\"\n }): Promise<Migration[]> {\n if (!this.isInitialized)\n throw new CannotExecuteNotConnectedError(this.name)\n\n const migrationExecutor = new MigrationExecutor(this)\n migrationExecutor.transaction =\n (options && options.transaction) || \"all\"\n\n const successMigrations =\n await migrationExecutor.executePendingMigrations()\n return successMigrations\n }\n\n /**\n * Reverts last executed migration.\n * Can be used only after connection to the database is established.\n */\n async undoLastMigration(options?: {\n transaction?: \"all\" | \"none\" | \"each\"\n }): Promise<void> {\n if (!this.isInitialized)\n throw new CannotExecuteNotConnectedError(this.name)\n\n const migrationExecutor = new MigrationExecutor(this)\n migrationExecutor.transaction =\n (options && options.transaction) || \"all\"\n\n await migrationExecutor.undoLastMigration()\n }\n\n /**\n * Lists all migrations and whether they have been run.\n * Returns true if there are pending migrations\n */\n async showMigrations(): Promise<boolean> {\n if (!this.isInitialized) {\n throw new CannotExecuteNotConnectedError(this.name)\n }\n const migrationExecutor = new MigrationExecutor(this)\n return await migrationExecutor.showMigrations()\n }\n\n /**\n * Checks if entity metadata exist for the given entity class, target name or table name.\n */\n hasMetadata(target: EntityTarget<any>): boolean {\n return !!this.findMetadata(target)\n }\n\n /**\n * Gets entity metadata for the given entity class or schema name.\n */\n getMetadata(target: EntityTarget<any>): EntityMetadata {\n const metadata = this.findMetadata(target)\n if (!metadata) throw new EntityMetadataNotFoundError(target)\n\n return metadata\n }\n\n /**\n * Gets repository for the given entity.\n */\n getRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): Repository<Entity> {\n return this.manager.getRepository(target)\n }\n\n /**\n * Gets tree repository for the given entity class or name.\n * Only tree-type entities can have a TreeRepository, like ones decorated with @Tree decorator.\n */\n getTreeRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): TreeRepository<Entity> {\n return this.manager.getTreeRepository(target)\n }\n\n /**\n * Gets mongodb-specific repository for the given entity class or name.\n * Works only if connection is mongodb-specific.\n */\n getMongoRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): MongoRepository<Entity> {\n if (!(this.driver.options.type === \"mongodb\"))\n throw new TypeORMError(\n `You can use getMongoRepository only for MongoDB connections.`,\n )\n\n return this.manager.getRepository(target) as any\n }\n\n /**\n * Gets custom entity repository marked with @EntityRepository decorator.\n *\n * @deprecated use Repository.extend function to create a custom repository\n */\n getCustomRepository<T>(customRepository: ObjectType<T>): T {\n return this.manager.getCustomRepository(customRepository)\n }\n\n /**\n * Wraps given function execution (and all operations made there) into a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n async transaction<T>(\n isolationLevel: IsolationLevel,\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n async transaction<T>(\n isolationOrRunInTransaction:\n | IsolationLevel\n | ((entityManager: EntityManager) => Promise<T>),\n runInTransactionParam?: (entityManager: EntityManager) => Promise<T>,\n ): Promise<any> {\n return this.manager.transaction(\n isolationOrRunInTransaction as any,\n runInTransactionParam as any,\n )\n }\n\n /**\n * Executes raw SQL query and returns raw database results.\n */\n async query(\n query: string,\n parameters?: any[],\n queryRunner?: QueryRunner,\n ): Promise<any> {\n if (InstanceChecker.isMongoEntityManager(this.manager))\n throw new TypeORMError(`Queries aren't supported by MongoDB.`)\n\n if (queryRunner && queryRunner.isReleased)\n throw new QueryRunnerProviderAlreadyReleasedError()\n\n const usedQueryRunner = queryRunner || this.createQueryRunner()\n\n try {\n return await usedQueryRunner.query(query, parameters) // await is needed here because we are using finally\n } finally {\n if (!queryRunner) await usedQueryRunner.release()\n }\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass: EntityTarget<Entity>,\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityOrRunner?: EntityTarget<Entity> | QueryRunner,\n alias?: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n if (InstanceChecker.isMongoEntityManager(this.manager))\n throw new TypeORMError(`Query Builder is not supported by MongoDB.`)\n\n if (alias) {\n alias = DriverUtils.buildAlias(this.driver, alias)\n const metadata = this.getMetadata(\n entityOrRunner as EntityTarget<Entity>,\n )\n return new SelectQueryBuilder(this, queryRunner)\n .select(alias)\n .from(metadata.target, alias)\n } else {\n return new SelectQueryBuilder(\n this,\n entityOrRunner as QueryRunner | undefined,\n )\n }\n }\n\n /**\n * Creates a query runner used for perform queries on a single database connection.\n * Using query runners you can control your queries to execute using single database connection and\n * manually control your database transaction.\n *\n * Mode is used in replication mode and indicates whatever you want to connect\n * to master database or any of slave databases.\n * If you perform writes you must use master database,\n * if you perform reads you can use slave databases.\n */\n createQueryRunner(mode: ReplicationMode = \"master\"): QueryRunner {\n const queryRunner = this.driver.createQueryRunner(mode)\n const manager = this.createEntityManager(queryRunner)\n Object.assign(queryRunner, { manager: manager })\n return queryRunner\n }\n\n /**\n * Gets entity metadata of the junction table (many-to-many table).\n */\n getManyToManyMetadata(\n entityTarget: EntityTarget<any>,\n relationPropertyPath: string,\n ) {\n const relationMetadata =\n this.getMetadata(entityTarget).findRelationWithPropertyPath(\n relationPropertyPath,\n )\n if (!relationMetadata)\n throw new TypeORMError(\n `Relation \"${relationPropertyPath}\" was not found in ${entityTarget} entity.`,\n )\n if (!relationMetadata.isManyToMany)\n throw new TypeORMError(\n `Relation \"${entityTarget}#${relationPropertyPath}\" does not have a many-to-many relationship.` +\n `You can use this method only on many-to-many relations.`,\n )\n\n return relationMetadata.junctionEntityMetadata\n }\n\n /**\n * Creates an Entity Manager for the current connection with the help of the EntityManagerFactory.\n */\n createEntityManager(queryRunner?: QueryRunner): EntityManager {\n return new EntityManagerFactory().create(this, queryRunner)\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Finds exist entity metadata by the given entity class, target name or table name.\n */\n protected findMetadata(\n target: EntityTarget<any>,\n ): EntityMetadata | undefined {\n return this.entityMetadatas.find((metadata) => {\n if (metadata.target === target) return true\n if (InstanceChecker.isEntitySchema(target)) {\n return metadata.name === target.options.name\n }\n if (typeof target === \"string\") {\n if (target.indexOf(\".\") !== -1) {\n return metadata.tablePath === target\n } else {\n return (\n metadata.name === target ||\n metadata.tableName === target\n )\n }\n }\n if (\n ObjectUtils.isObject(target) &&\n typeof target.name === \"string\"\n ) {\n if (target.name.indexOf(\".\") !== -1) {\n return metadata.tablePath === target.name\n } else {\n return (\n metadata.name === target.name ||\n metadata.tableName === target.name\n )\n }\n }\n\n return false\n })\n }\n\n /**\n * Builds metadatas for all registered classes inside this connection.\n */\n protected async buildMetadatas(): Promise<void> {\n const connectionMetadataBuilder = new ConnectionMetadataBuilder(this)\n const entityMetadataValidator = new EntityMetadataValidator()\n\n // create subscribers instances if they are not disallowed from high-level (for example they can disallowed from migrations run process)\n const flattenedSubscribers = ObjectUtils.mixedListToArray(\n this.options.subscribers || [],\n )\n const subscribers = await connectionMetadataBuilder.buildSubscribers(\n flattenedSubscribers,\n )\n ObjectUtils.assign(this, { subscribers: subscribers })\n\n // build entity metadatas\n const flattenedEntities = ObjectUtils.mixedListToArray(\n this.options.entities || [],\n )\n const entityMetadatas =\n await connectionMetadataBuilder.buildEntityMetadatas(\n flattenedEntities,\n )\n ObjectUtils.assign(this, { entityMetadatas: entityMetadatas })\n\n // create migration instances\n const flattenedMigrations = ObjectUtils.mixedListToArray(\n this.options.migrations || [],\n )\n const migrations = await connectionMetadataBuilder.buildMigrations(\n flattenedMigrations,\n )\n ObjectUtils.assign(this, { migrations: migrations })\n\n // validate all created entity metadatas to make sure user created entities are valid and correct\n entityMetadataValidator.validateMany(\n this.entityMetadatas.filter(\n (metadata) => metadata.tableType !== \"view\",\n ),\n this.driver,\n )\n\n // set current data source to the entities\n for (let entityMetadata of entityMetadatas) {\n if (\n InstanceChecker.isBaseEntityConstructor(entityMetadata.target)\n ) {\n entityMetadata.target.useDataSource(this)\n }\n }\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -20,6 +20,7 @@ import { DeleteResult } from "../query-builder/result/DeleteResult";
|
|
|
20
20
|
import { FindOptionsWhere } from "../find-options/FindOptionsWhere";
|
|
21
21
|
import { IsolationLevel } from "../driver/types/IsolationLevel";
|
|
22
22
|
import { UpsertOptions } from "../repository/UpsertOptions";
|
|
23
|
+
import { ObjectLiteral } from "../common/ObjectLiteral";
|
|
23
24
|
/**
|
|
24
25
|
* Entity manager supposed to work with any entity, automatically find its repository and call its methods,
|
|
25
26
|
* whatever entity type are you passing.
|
|
@@ -99,14 +100,14 @@ export declare class EntityManager {
|
|
|
99
100
|
/**
|
|
100
101
|
* Merges two entities into one new entity.
|
|
101
102
|
*/
|
|
102
|
-
merge<Entity>(entityClass: EntityTarget<Entity>, mergeIntoEntity: Entity, ...entityLikes: DeepPartial<Entity>[]): Entity;
|
|
103
|
+
merge<Entity extends ObjectLiteral>(entityClass: EntityTarget<Entity>, mergeIntoEntity: Entity, ...entityLikes: DeepPartial<Entity>[]): Entity;
|
|
103
104
|
/**
|
|
104
105
|
* Creates a new entity from the given plain javascript object. If entity already exist in the database, then
|
|
105
106
|
* it loads it (and everything related to it), replaces all values with the new ones from the given object
|
|
106
107
|
* and returns this new entity. This new entity is actually a loaded from the db entity with all properties
|
|
107
108
|
* replaced from the new object.
|
|
108
109
|
*/
|
|
109
|
-
preload<Entity>(entityClass: EntityTarget<Entity>, entityLike: DeepPartial<Entity>): Promise<Entity | undefined>;
|
|
110
|
+
preload<Entity extends ObjectLiteral>(entityClass: EntityTarget<Entity>, entityLike: DeepPartial<Entity>): Promise<Entity | undefined>;
|
|
110
111
|
/**
|
|
111
112
|
* Saves all given entities in the database.
|
|
112
113
|
* If entities do not exist in the database then inserts, otherwise updates.
|
|
@@ -221,7 +222,7 @@ export declare class EntityManager {
|
|
|
221
222
|
* Does not check if entity exist in the database.
|
|
222
223
|
* Condition(s) cannot be empty.
|
|
223
224
|
*/
|
|
224
|
-
softDelete<Entity>(targetOrEntity: EntityTarget<Entity>, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | any): Promise<UpdateResult>;
|
|
225
|
+
softDelete<Entity extends ObjectLiteral>(targetOrEntity: EntityTarget<Entity>, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | any): Promise<UpdateResult>;
|
|
225
226
|
/**
|
|
226
227
|
* Restores entities by a given condition(s).
|
|
227
228
|
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
@@ -229,7 +230,7 @@ export declare class EntityManager {
|
|
|
229
230
|
* Does not check if entity exist in the database.
|
|
230
231
|
* Condition(s) cannot be empty.
|
|
231
232
|
*/
|
|
232
|
-
restore<Entity>(targetOrEntity: EntityTarget<Entity>, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | any): Promise<UpdateResult>;
|
|
233
|
+
restore<Entity extends ObjectLiteral>(targetOrEntity: EntityTarget<Entity>, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | any): Promise<UpdateResult>;
|
|
233
234
|
/**
|
|
234
235
|
* Counts entities that match given options.
|
|
235
236
|
* Useful for pagination.
|
|
@@ -323,24 +324,24 @@ export declare class EntityManager {
|
|
|
323
324
|
* repository aggregator, where each repository is individually created for this entity manager.
|
|
324
325
|
* When single database connection is not used, repository is being obtained from the connection.
|
|
325
326
|
*/
|
|
326
|
-
getRepository<Entity>(target: EntityTarget<Entity>): Repository<Entity>;
|
|
327
|
+
getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity>;
|
|
327
328
|
/**
|
|
328
329
|
* Gets tree repository for the given entity class or name.
|
|
329
330
|
* If single database connection mode is used, then repository is obtained from the
|
|
330
331
|
* repository aggregator, where each repository is individually created for this entity manager.
|
|
331
332
|
* When single database connection is not used, repository is being obtained from the connection.
|
|
332
333
|
*/
|
|
333
|
-
getTreeRepository<Entity>(target: EntityTarget<Entity>): TreeRepository<Entity>;
|
|
334
|
+
getTreeRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): TreeRepository<Entity>;
|
|
334
335
|
/**
|
|
335
336
|
* Gets mongodb repository for the given entity class.
|
|
336
337
|
*/
|
|
337
|
-
getMongoRepository<Entity>(target: EntityTarget<Entity>): MongoRepository<Entity>;
|
|
338
|
+
getMongoRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): MongoRepository<Entity>;
|
|
338
339
|
/**
|
|
339
340
|
* Creates a new repository instance out of a given Repository and
|
|
340
341
|
* sets current EntityManager instance to it. Used to work with custom repositories
|
|
341
342
|
* in transactions.
|
|
342
343
|
*/
|
|
343
|
-
withRepository<Entity, R extends Repository<Entity>>(repository: R): R;
|
|
344
|
+
withRepository<Entity extends ObjectLiteral, R extends Repository<Entity>>(repository: R): R;
|
|
344
345
|
/**
|
|
345
346
|
* Gets custom entity repository marked with @EntityRepository decorator.
|
|
346
347
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/entity-manager/EntityManager.ts"],"names":[],"mappings":";;;AAIA,sEAAkE;AAClE,8GAA0G;AAK1G,kGAA8F;AAC9F,mEAA+D;AAC/D,iEAA6D;AAC7D,yDAAqD;AACrD,uEAAmE;AACnE,sHAAkH;AAClH,gIAA4H;AAC5H,oCAKiB;AACjB,yEAAqE;AAIrE,gFAA4E;AAO5E,qDAAiD;AACjD,wCAAmD;AAEnD,6DAAyD;AAEzD;;;GAGG;AACH,MAAa,aAAa;IAsCtB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,UAAsB,EAAE,WAAyB;QAzCpD,mBAAa,GAAG,MAAM,CAAC,GAAG,C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,SAAS,CAAC,GAAG,IAAI,CAAA;SAC1D;aAAM;YACH,IAAI,CAAC,cAAc;gBACf,MAAM,IAAI,oDAA4C,CAClD,gBAAgB,CACnB,CACJ;YAAC,wBAAgC,CAAC,SAAS,CAAC,GAAG,IAAI,CACnD;YAAC,wBAAgC,CAAC,UAAU,CAAC,GAAG,cAAc,CAAA;SAClE;QAED,OAAO,wBAAwB,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,qEAAiC,EAAE,CAAA;QAEpE,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;IACrC,CAAC;CACJ;AAh2CD,sCAg2CC","file":"EntityManager.js","sourcesContent":["import { DataSource } from \"../data-source/DataSource\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { ObjectType } from \"../common/ObjectType\"\nimport { EntityNotFoundError } from \"../error/EntityNotFoundError\"\nimport { QueryRunnerProviderAlreadyReleasedError } from \"../error/QueryRunnerProviderAlreadyReleasedError\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { RemoveOptions } from \"../repository/RemoveOptions\"\nimport { SaveOptions } from \"../repository/SaveOptions\"\nimport { NoNeedToReleaseEntityManagerError } from \"../error/NoNeedToReleaseEntityManagerError\"\nimport { MongoRepository } from \"../repository/MongoRepository\"\nimport { TreeRepository } from \"../repository/TreeRepository\"\nimport { Repository } from \"../repository/Repository\"\nimport { FindOptionsUtils } from \"../find-options/FindOptionsUtils\"\nimport { PlainObjectToNewEntityTransformer } from \"../query-builder/transformer/PlainObjectToNewEntityTransformer\"\nimport { PlainObjectToDatabaseEntityTransformer } from \"../query-builder/transformer/PlainObjectToDatabaseEntityTransformer\"\nimport {\n CustomRepositoryCannotInheritRepositoryError,\n CustomRepositoryNotFoundError,\n TreeRepositoryNotSupportedError,\n TypeORMError,\n} from \"../error\"\nimport { AbstractRepository } from \"../repository/AbstractRepository\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { EntityPersistExecutor } from \"../persistence/EntityPersistExecutor\"\nimport { ObjectID } from \"../driver/mongodb/typings\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { IsolationLevel } from \"../driver/types/IsolationLevel\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { getMetadataArgsStorage } from \"../globals\"\nimport { UpsertOptions } from \"../repository/UpsertOptions\"\nimport { InstanceChecker } from \"../util/InstanceChecker\"\n\n/**\n * Entity manager supposed to work with any entity, automatically find its repository and call its methods,\n * whatever entity type are you passing.\n */\nexport class EntityManager {\n readonly \"@instanceof\" = Symbol.for(\"EntityManager\")\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by this entity manager.\n */\n readonly connection: DataSource\n\n /**\n * Custom query runner to be used for operations in this entity manager.\n * Used only in non-global entity manager.\n */\n readonly queryRunner?: QueryRunner\n\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Once created and then reused by repositories.\n */\n protected repositories: Repository<any>[] = []\n\n /**\n * Once created and then reused by repositories.\n */\n protected treeRepositories: TreeRepository<any>[] = []\n\n /**\n * Plain to object transformer used in create and merge operations.\n */\n protected plainObjectToEntityTransformer =\n new PlainObjectToNewEntityTransformer()\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource, queryRunner?: QueryRunner) {\n this.connection = connection\n if (queryRunner) {\n this.queryRunner = queryRunner\n // dynamic: this.queryRunner = manager;\n ObjectUtils.assign(this.queryRunner, { manager: this })\n }\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n isolationLevel: IsolationLevel,\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n isolationOrRunInTransaction:\n | IsolationLevel\n | ((entityManager: EntityManager) => Promise<T>),\n runInTransactionParam?: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T> {\n const isolation =\n typeof isolationOrRunInTransaction === \"string\"\n ? isolationOrRunInTransaction\n : undefined\n const runInTransaction =\n typeof isolationOrRunInTransaction === \"function\"\n ? isolationOrRunInTransaction\n : runInTransactionParam\n\n if (!runInTransaction) {\n throw new TypeORMError(\n `Transaction method requires callback in second parameter if isolation level is supplied.`,\n )\n }\n\n if (this.queryRunner && this.queryRunner.isReleased)\n throw new QueryRunnerProviderAlreadyReleasedError()\n\n // if query runner is already defined in this class, it means this entity manager was already created for a single connection\n // if its not defined we create a new query runner - single connection where we'll execute all our operations\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n try {\n await queryRunner.startTransaction(isolation)\n const result = await runInTransaction(queryRunner.manager)\n await queryRunner.commitTransaction()\n return result\n } catch (err) {\n try {\n // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n throw err\n } finally {\n if (!this.queryRunner)\n // if we used a new query runner provider then release it\n await queryRunner.release()\n }\n }\n\n /**\n * Executes raw SQL query and returns raw database results.\n */\n async query(query: string, parameters?: any[]): Promise<any> {\n return this.connection.query(query, parameters, this.queryRunner)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass: EntityTarget<Entity>,\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass?: EntityTarget<Entity> | QueryRunner,\n alias?: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n if (alias) {\n return this.connection.createQueryBuilder(\n entityClass as EntityTarget<Entity>,\n alias,\n queryRunner || this.queryRunner,\n )\n } else {\n return this.connection.createQueryBuilder(\n (entityClass as QueryRunner | undefined) ||\n queryRunner ||\n this.queryRunner,\n )\n }\n }\n\n /**\n * Checks if entity has an id.\n */\n hasId(entity: any): boolean\n\n /**\n * Checks if entity of given schema name has an id.\n */\n hasId(target: Function | string, entity: any): boolean\n\n /**\n * Checks if entity has an id by its Function type or schema name.\n */\n hasId(targetOrEntity: any | Function | string, maybeEntity?: any): boolean {\n const target =\n arguments.length === 2 ? targetOrEntity : targetOrEntity.constructor\n const entity = arguments.length === 2 ? maybeEntity : targetOrEntity\n const metadata = this.connection.getMetadata(target)\n return metadata.hasId(entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: any): any\n\n /**\n * Gets entity mixed id.\n */\n getId(target: EntityTarget<any>, entity: any): any\n\n /**\n * Gets entity mixed id.\n */\n getId(targetOrEntity: any | EntityTarget<any>, maybeEntity?: any): any {\n const target =\n arguments.length === 2 ? targetOrEntity : targetOrEntity.constructor\n const entity = arguments.length === 2 ? maybeEntity : targetOrEntity\n const metadata = this.connection.getMetadata(target)\n return metadata.getEntityIdMixedMap(entity)\n }\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObject?: DeepPartial<Entity>,\n ): Entity\n\n /**\n * Creates a new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that present in entity schema.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObjects?: DeepPartial<Entity>[],\n ): Entity[]\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObjectOrObjects?: DeepPartial<Entity> | DeepPartial<Entity>[],\n ): Entity | Entity[] {\n const metadata = this.connection.getMetadata(entityClass)\n\n if (!plainObjectOrObjects) return metadata.create(this.queryRunner)\n\n if (Array.isArray(plainObjectOrObjects))\n return (plainObjectOrObjects as DeepPartial<Entity>[]).map(\n (plainEntityLike) => this.create(entityClass, plainEntityLike),\n )\n\n const mergeIntoEntity = metadata.create(this.queryRunner)\n this.plainObjectToEntityTransformer.transform(\n mergeIntoEntity,\n plainObjectOrObjects,\n metadata,\n true,\n )\n return mergeIntoEntity\n }\n\n /**\n * Merges two entities into one new entity.\n */\n merge<Entity>(\n entityClass: EntityTarget<Entity>,\n mergeIntoEntity: Entity,\n ...entityLikes: DeepPartial<Entity>[]\n ): Entity {\n // todo: throw exception if entity manager is released\n const metadata = this.connection.getMetadata(entityClass)\n entityLikes.forEach((object) =>\n this.plainObjectToEntityTransformer.transform(\n mergeIntoEntity,\n object,\n metadata,\n ),\n )\n return mergeIntoEntity\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n */\n async preload<Entity>(\n entityClass: EntityTarget<Entity>,\n entityLike: DeepPartial<Entity>,\n ): Promise<Entity | undefined> {\n const metadata = this.connection.getMetadata(entityClass)\n const plainObjectToDatabaseEntityTransformer =\n new PlainObjectToDatabaseEntityTransformer(this.connection.manager)\n const transformedEntity =\n await plainObjectToDatabaseEntityTransformer.transform(\n entityLike,\n metadata,\n )\n if (transformedEntity)\n return this.merge(\n entityClass as any,\n transformedEntity as Entity,\n entityLike,\n )\n\n return undefined\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity>(entities: Entity[], options?: SaveOptions): Promise<Entity[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Saves a given entity in the database.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute save operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"save\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(entity: Entity, options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n entity: Entity,\n options?: RemoveOptions,\n ): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(entity: Entity[], options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n entity: Entity[],\n options?: RemoveOptions,\n ): Promise<Entity[]>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(\n targetOrEntity: (Entity | Entity[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: Entity | Entity[],\n maybeOptions?: RemoveOptions,\n ): Promise<Entity | Entity[]> {\n // normalize mixed parameters\n const target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: Entity | Entity[] = target\n ? (maybeEntityOrOptions as Entity | Entity[])\n : (targetOrEntity as Entity | Entity[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute save operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"remove\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<Entity>(\n entities: Entity[],\n options?: SaveOptions,\n ): Promise<Entity[]>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute soft-remove operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"soft-remove\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Recovers all given entities.\n */\n recover<Entity>(\n entities: Entity[],\n options?: SaveOptions,\n ): Promise<Entity[]>\n\n /**\n * Recovers a given entity.\n */\n recover<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Recovers all given entities.\n */\n recover<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Recovers a given entity.\n */\n recover<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Recovers one or many given entities.\n */\n recover<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute recover operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"recover\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n * You can execute bulk inserts using this method.\n */\n async insert<Entity>(\n target: EntityTarget<Entity>,\n entity:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n ): Promise<InsertResult> {\n return this.createQueryBuilder()\n .insert()\n .into(target)\n .values(entity)\n .execute()\n }\n\n async upsert<Entity>(\n target: EntityTarget<Entity>,\n entityOrEntities:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>,\n ): Promise<InsertResult> {\n const metadata = this.connection.getMetadata(target)\n\n let options: UpsertOptions<Entity>\n\n if (Array.isArray(conflictPathsOrOptions)) {\n options = {\n conflictPaths: conflictPathsOrOptions,\n }\n } else {\n options = conflictPathsOrOptions\n }\n\n let entities: QueryDeepPartialEntity<Entity>[]\n\n if (!Array.isArray(entityOrEntities)) {\n entities = [entityOrEntities]\n } else {\n entities = entityOrEntities\n }\n\n const conflictColumns = metadata.mapPropertyPathsToColumns(\n options.conflictPaths,\n )\n\n const overwriteColumns = metadata.columns.filter(\n (col) =>\n !conflictColumns.includes(col) &&\n entities.some(\n (entity) =>\n typeof col.getEntityValue(entity) !== \"undefined\",\n ),\n )\n\n return this.createQueryBuilder()\n .insert()\n .into(target)\n .values(entities)\n .orUpdate(\n [...conflictColumns, ...overwriteColumns].map(\n (col) => col.databaseName,\n ),\n conflictColumns.map((col) => col.databaseName),\n {\n skipUpdateIfNoValuesChanged:\n options.skipUpdateIfNoValuesChanged,\n },\n )\n .execute()\n }\n\n /**\n * Updates entity partially. Entity can be found by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n update<Entity>(\n target: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n partialEntity: QueryDeepPartialEntity<Entity>,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the update method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Deletes entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n delete<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<DeleteResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .delete()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .delete()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Records the delete date of entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n softDelete<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .softDelete()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .softDelete()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Restores entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n restore<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .restore()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .restore()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Counts entities that match given options.\n * Useful for pagination.\n */\n count<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<number> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(\n entityClass,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getCount()\n }\n\n /**\n * Counts entities that match given conditions.\n * Useful for pagination.\n */\n countBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(entityClass, metadata.name)\n .setFindOptions({ where })\n .getCount()\n }\n\n /**\n * Finds entities that match given find options.\n */\n async find<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<Entity[]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getMany()\n }\n\n /**\n * Finds entities that match given find options.\n */\n async findBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity[]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .setFindOptions({ where: where })\n .getMany()\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getManyAndCount()\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<[Entity[], number]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .setFindOptions({ where })\n .getManyAndCount()\n }\n\n /**\n * Finds entities with ids.\n * Optionally find options or conditions can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n async findByIds<Entity>(\n entityClass: EntityTarget<Entity>,\n ids: any[],\n ): Promise<Entity[]> {\n // if no ids passed, no need to execute a query - just return an empty array of values\n if (!ids.length) return Promise.resolve([])\n\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .andWhereInIds(ids)\n .getMany()\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - returns null.\n */\n async findOne<Entity>(\n entityClass: EntityTarget<Entity>,\n options: FindOneOptions<Entity>,\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // prepare alias for built query\n let alias: string = metadata.name\n if (options && options.join) {\n alias = options.join.alias\n }\n\n if (!options.where) {\n throw new Error(\n `You must provide selection conditions in order to find a single row.`,\n )\n }\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, alias)\n .setFindOptions({\n ...options,\n take: 1,\n })\n .getOne()\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - returns null.\n */\n async findOneBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, metadata.name)\n .setFindOptions({\n where,\n take: 1,\n })\n .getOne()\n }\n\n /**\n * Finds first entity that matches given id.\n * If entity was not found in the database - returns null.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById<Entity>(\n entityClass: EntityTarget<Entity>,\n id: number | string | Date | ObjectID,\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, metadata.name)\n .setFindOptions({\n take: 1,\n })\n .whereInIds(metadata.ensureEntityIdMap(id))\n .getOne()\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail<Entity>(\n entityClass: EntityTarget<Entity>,\n options: FindOneOptions<Entity>,\n ): Promise<Entity> {\n return this.findOne<Entity>(entityClass as any, options).then(\n (value) => {\n if (value === null) {\n return Promise.reject(\n new EntityNotFoundError(entityClass, options),\n )\n }\n return Promise.resolve(value)\n },\n )\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity> {\n return this.findOneBy<Entity>(entityClass as any, where).then(\n (value) => {\n if (value === null) {\n return Promise.reject(\n new EntityNotFoundError(entityClass, where),\n )\n }\n return Promise.resolve(value)\n },\n )\n }\n\n /**\n * Clears all the data from the given table (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n async clear<Entity>(entityClass: EntityTarget<Entity>): Promise<void> {\n const metadata = this.connection.getMetadata(entityClass)\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n try {\n return await queryRunner.clearTable(metadata.tablePath) // await is needed here because we are using finally\n } finally {\n if (!this.queryRunner) await queryRunner.release()\n }\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n async increment<Entity>(\n entityClass: EntityTarget<Entity>,\n conditions: any,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.findColumnWithPropertyPath(propertyPath)\n if (!column)\n throw new TypeORMError(\n `Column ${propertyPath} was not found in ${metadata.targetName} entity.`,\n )\n\n if (isNaN(Number(value)))\n throw new TypeORMError(`Value \"${value}\" is not a number.`)\n\n // convert possible embeded path \"social.likes\" into object { social: { like: () => value } }\n const values: QueryDeepPartialEntity<Entity> = propertyPath\n .split(\".\")\n .reduceRight(\n (value, key) => ({ [key]: value } as any),\n () =>\n this.connection.driver.escape(column.databaseName) +\n \" + \" +\n value,\n )\n\n return this.createQueryBuilder<Entity>(entityClass as any, \"entity\")\n .update(entityClass)\n .set(values)\n .where(conditions)\n .execute()\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n async decrement<Entity>(\n entityClass: EntityTarget<Entity>,\n conditions: any,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.findColumnWithPropertyPath(propertyPath)\n if (!column)\n throw new TypeORMError(\n `Column ${propertyPath} was not found in ${metadata.targetName} entity.`,\n )\n\n if (isNaN(Number(value)))\n throw new TypeORMError(`Value \"${value}\" is not a number.`)\n\n // convert possible embeded path \"social.likes\" into object { social: { like: () => value } }\n const values: QueryDeepPartialEntity<Entity> = propertyPath\n .split(\".\")\n .reduceRight(\n (value, key) => ({ [key]: value } as any),\n () =>\n this.connection.driver.escape(column.databaseName) +\n \" - \" +\n value,\n )\n\n return this.createQueryBuilder<Entity>(entityClass as any, \"entity\")\n .update(entityClass)\n .set(values)\n .where(conditions)\n .execute()\n }\n\n /**\n * Gets repository for the given entity class or name.\n * If single database connection mode is used, then repository is obtained from the\n * repository aggregator, where each repository is individually created for this entity manager.\n * When single database connection is not used, repository is being obtained from the connection.\n */\n getRepository<Entity>(target: EntityTarget<Entity>): Repository<Entity> {\n // find already created repository instance and return it if found\n const repository = this.repositories.find(\n (repository) => repository.target === target,\n )\n if (repository) return repository\n\n // if repository was not found then create it, store its instance and return it\n if (this.connection.driver.options.type === \"mongodb\") {\n const newRepository = new MongoRepository(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.push(newRepository as any)\n return newRepository\n } else {\n const newRepository = new Repository<any>(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.push(newRepository)\n return newRepository\n }\n }\n\n /**\n * Gets tree repository for the given entity class or name.\n * If single database connection mode is used, then repository is obtained from the\n * repository aggregator, where each repository is individually created for this entity manager.\n * When single database connection is not used, repository is being obtained from the connection.\n */\n getTreeRepository<Entity>(\n target: EntityTarget<Entity>,\n ): TreeRepository<Entity> {\n // tree tables aren't supported by some drivers (mongodb)\n if (this.connection.driver.treeSupport === false)\n throw new TreeRepositoryNotSupportedError(this.connection.driver)\n\n // find already created repository instance and return it if found\n const repository = this.treeRepositories.find(\n (repository) => repository.target === target,\n )\n if (repository) return repository\n\n // check if repository is real tree repository\n const newRepository = new TreeRepository(target, this, this.queryRunner)\n this.treeRepositories.push(newRepository)\n return newRepository\n }\n\n /**\n * Gets mongodb repository for the given entity class.\n */\n getMongoRepository<Entity>(\n target: EntityTarget<Entity>,\n ): MongoRepository<Entity> {\n return this.connection.getMongoRepository<Entity>(target)\n }\n\n /**\n * Creates a new repository instance out of a given Repository and\n * sets current EntityManager instance to it. Used to work with custom repositories\n * in transactions.\n */\n withRepository<Entity, R extends Repository<Entity>>(repository: R): R {\n const repositoryConstructor =\n repository.constructor as typeof Repository\n const { target, manager, queryRunner, ...otherRepositoryProperties } =\n repository\n return Object.assign(\n new repositoryConstructor(repository.target, this) as R,\n {\n ...otherRepositoryProperties,\n },\n )\n }\n\n /**\n * Gets custom entity repository marked with @EntityRepository decorator.\n *\n * @deprecated use Repository.extend to create custom repositories\n */\n getCustomRepository<T>(customRepository: ObjectType<T>): T {\n const entityRepositoryMetadataArgs =\n getMetadataArgsStorage().entityRepositories.find((repository) => {\n return (\n repository.target ===\n (typeof customRepository === \"function\"\n ? customRepository\n : (customRepository as any).constructor)\n )\n })\n if (!entityRepositoryMetadataArgs)\n throw new CustomRepositoryNotFoundError(customRepository)\n\n const entityMetadata = entityRepositoryMetadataArgs.entity\n ? this.connection.getMetadata(entityRepositoryMetadataArgs.entity)\n : undefined\n const entityRepositoryInstance =\n new (entityRepositoryMetadataArgs.target as any)(\n this,\n entityMetadata,\n )\n\n // NOTE: dynamic access to protected properties. We need this to prevent unwanted properties in those classes to be exposed,\n // however we need these properties for internal work of the class\n if (entityRepositoryInstance instanceof AbstractRepository) {\n if (!(entityRepositoryInstance as any)[\"manager\"])\n (entityRepositoryInstance as any)[\"manager\"] = this\n } else {\n if (!entityMetadata)\n throw new CustomRepositoryCannotInheritRepositoryError(\n customRepository,\n )\n ;(entityRepositoryInstance as any)[\"manager\"] = this\n ;(entityRepositoryInstance as any)[\"metadata\"] = entityMetadata\n }\n\n return entityRepositoryInstance\n }\n\n /**\n * Releases all resources used by entity manager.\n * This is used when entity manager is created with a single query runner,\n * and this single query runner needs to be released after job with entity manager is done.\n */\n async release(): Promise<void> {\n if (!this.queryRunner) throw new NoNeedToReleaseEntityManagerError()\n\n return this.queryRunner.release()\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/entity-manager/EntityManager.ts"],"names":[],"mappings":";;;AAIA,sEAAkE;AAClE,8GAA0G;AAK1G,kGAA8F;AAC9F,mEAA+D;AAC/D,iEAA6D;AAC7D,yDAAqD;AACrD,uEAAmE;AACnE,sHAAkH;AAClH,gIAA4H;AAC5H,oCAKiB;AACjB,yEAAqE;AAIrE,gFAA4E;AAO5E,qDAAiD;AACjD,wCAAmD;AAEnD,6DAAyD;AAGzD;;;GAGG;AACH,MAAa,aAAa;IAsCtB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,UAAsB,EAAE,WAAyB;QAzCpD,mBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAiBpD,4EAA4E;QAC5E,uBAAuB;QACvB,4EAA4E;QAE5E;;WAEG;QACO,iBAAY,GAAsB,EAAE,CAAA;QAE9C;;WAEG;QACO,qBAAgB,GAA0B,EAAE,CAAA;QAEtD;;WAEG;QACO,mCAA8B,GACpC,IAAI,qEAAiC,EAAE,CAAA;QAOvC,IAAI,CAAC,UAAU,GAAG,UAAU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;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,qEAAiC,EAAE,CAAA;QAEpE,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;IACrC,CAAC;CACJ;AAp2CD,sCAo2CC","file":"EntityManager.js","sourcesContent":["import { DataSource } from \"../data-source/DataSource\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { ObjectType } from \"../common/ObjectType\"\nimport { EntityNotFoundError } from \"../error/EntityNotFoundError\"\nimport { QueryRunnerProviderAlreadyReleasedError } from \"../error/QueryRunnerProviderAlreadyReleasedError\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { RemoveOptions } from \"../repository/RemoveOptions\"\nimport { SaveOptions } from \"../repository/SaveOptions\"\nimport { NoNeedToReleaseEntityManagerError } from \"../error/NoNeedToReleaseEntityManagerError\"\nimport { MongoRepository } from \"../repository/MongoRepository\"\nimport { TreeRepository } from \"../repository/TreeRepository\"\nimport { Repository } from \"../repository/Repository\"\nimport { FindOptionsUtils } from \"../find-options/FindOptionsUtils\"\nimport { PlainObjectToNewEntityTransformer } from \"../query-builder/transformer/PlainObjectToNewEntityTransformer\"\nimport { PlainObjectToDatabaseEntityTransformer } from \"../query-builder/transformer/PlainObjectToDatabaseEntityTransformer\"\nimport {\n CustomRepositoryCannotInheritRepositoryError,\n CustomRepositoryNotFoundError,\n TreeRepositoryNotSupportedError,\n TypeORMError,\n} from \"../error\"\nimport { AbstractRepository } from \"../repository/AbstractRepository\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { EntityPersistExecutor } from \"../persistence/EntityPersistExecutor\"\nimport { ObjectID } from \"../driver/mongodb/typings\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { IsolationLevel } from \"../driver/types/IsolationLevel\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { getMetadataArgsStorage } from \"../globals\"\nimport { UpsertOptions } from \"../repository/UpsertOptions\"\nimport { InstanceChecker } from \"../util/InstanceChecker\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\n\n/**\n * Entity manager supposed to work with any entity, automatically find its repository and call its methods,\n * whatever entity type are you passing.\n */\nexport class EntityManager {\n readonly \"@instanceof\" = Symbol.for(\"EntityManager\")\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by this entity manager.\n */\n readonly connection: DataSource\n\n /**\n * Custom query runner to be used for operations in this entity manager.\n * Used only in non-global entity manager.\n */\n readonly queryRunner?: QueryRunner\n\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Once created and then reused by repositories.\n */\n protected repositories: Repository<any>[] = []\n\n /**\n * Once created and then reused by repositories.\n */\n protected treeRepositories: TreeRepository<any>[] = []\n\n /**\n * Plain to object transformer used in create and merge operations.\n */\n protected plainObjectToEntityTransformer =\n new PlainObjectToNewEntityTransformer()\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource, queryRunner?: QueryRunner) {\n this.connection = connection\n if (queryRunner) {\n this.queryRunner = queryRunner\n // dynamic: this.queryRunner = manager;\n ObjectUtils.assign(this.queryRunner, { manager: this })\n }\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n isolationLevel: IsolationLevel,\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n isolationOrRunInTransaction:\n | IsolationLevel\n | ((entityManager: EntityManager) => Promise<T>),\n runInTransactionParam?: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T> {\n const isolation =\n typeof isolationOrRunInTransaction === \"string\"\n ? isolationOrRunInTransaction\n : undefined\n const runInTransaction =\n typeof isolationOrRunInTransaction === \"function\"\n ? isolationOrRunInTransaction\n : runInTransactionParam\n\n if (!runInTransaction) {\n throw new TypeORMError(\n `Transaction method requires callback in second parameter if isolation level is supplied.`,\n )\n }\n\n if (this.queryRunner && this.queryRunner.isReleased)\n throw new QueryRunnerProviderAlreadyReleasedError()\n\n // if query runner is already defined in this class, it means this entity manager was already created for a single connection\n // if its not defined we create a new query runner - single connection where we'll execute all our operations\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n try {\n await queryRunner.startTransaction(isolation)\n const result = await runInTransaction(queryRunner.manager)\n await queryRunner.commitTransaction()\n return result\n } catch (err) {\n try {\n // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n throw err\n } finally {\n if (!this.queryRunner)\n // if we used a new query runner provider then release it\n await queryRunner.release()\n }\n }\n\n /**\n * Executes raw SQL query and returns raw database results.\n */\n async query(query: string, parameters?: any[]): Promise<any> {\n return this.connection.query(query, parameters, this.queryRunner)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass: EntityTarget<Entity>,\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass?: EntityTarget<Entity> | QueryRunner,\n alias?: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n if (alias) {\n return this.connection.createQueryBuilder(\n entityClass as EntityTarget<Entity>,\n alias,\n queryRunner || this.queryRunner,\n )\n } else {\n return this.connection.createQueryBuilder(\n (entityClass as QueryRunner | undefined) ||\n queryRunner ||\n this.queryRunner,\n )\n }\n }\n\n /**\n * Checks if entity has an id.\n */\n hasId(entity: any): boolean\n\n /**\n * Checks if entity of given schema name has an id.\n */\n hasId(target: Function | string, entity: any): boolean\n\n /**\n * Checks if entity has an id by its Function type or schema name.\n */\n hasId(targetOrEntity: any | Function | string, maybeEntity?: any): boolean {\n const target =\n arguments.length === 2 ? targetOrEntity : targetOrEntity.constructor\n const entity = arguments.length === 2 ? maybeEntity : targetOrEntity\n const metadata = this.connection.getMetadata(target)\n return metadata.hasId(entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: any): any\n\n /**\n * Gets entity mixed id.\n */\n getId(target: EntityTarget<any>, entity: any): any\n\n /**\n * Gets entity mixed id.\n */\n getId(targetOrEntity: any | EntityTarget<any>, maybeEntity?: any): any {\n const target =\n arguments.length === 2 ? targetOrEntity : targetOrEntity.constructor\n const entity = arguments.length === 2 ? maybeEntity : targetOrEntity\n const metadata = this.connection.getMetadata(target)\n return metadata.getEntityIdMixedMap(entity)\n }\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObject?: DeepPartial<Entity>,\n ): Entity\n\n /**\n * Creates a new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that present in entity schema.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObjects?: DeepPartial<Entity>[],\n ): Entity[]\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObjectOrObjects?: DeepPartial<Entity> | DeepPartial<Entity>[],\n ): Entity | Entity[] {\n const metadata = this.connection.getMetadata(entityClass)\n\n if (!plainObjectOrObjects) return metadata.create(this.queryRunner)\n\n if (Array.isArray(plainObjectOrObjects))\n return (plainObjectOrObjects as DeepPartial<Entity>[]).map(\n (plainEntityLike) => this.create(entityClass, plainEntityLike),\n )\n\n const mergeIntoEntity = metadata.create(this.queryRunner)\n this.plainObjectToEntityTransformer.transform(\n mergeIntoEntity,\n plainObjectOrObjects,\n metadata,\n true,\n )\n return mergeIntoEntity\n }\n\n /**\n * Merges two entities into one new entity.\n */\n merge<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n mergeIntoEntity: Entity,\n ...entityLikes: DeepPartial<Entity>[]\n ): Entity {\n // todo: throw exception if entity manager is released\n const metadata = this.connection.getMetadata(entityClass)\n entityLikes.forEach((object) =>\n this.plainObjectToEntityTransformer.transform(\n mergeIntoEntity,\n object,\n metadata,\n ),\n )\n return mergeIntoEntity\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n */\n async preload<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n entityLike: DeepPartial<Entity>,\n ): Promise<Entity | undefined> {\n const metadata = this.connection.getMetadata(entityClass)\n const plainObjectToDatabaseEntityTransformer =\n new PlainObjectToDatabaseEntityTransformer(this.connection.manager)\n const transformedEntity =\n await plainObjectToDatabaseEntityTransformer.transform(\n entityLike,\n metadata,\n )\n if (transformedEntity)\n return this.merge(\n entityClass as any,\n transformedEntity as Entity,\n entityLike,\n )\n\n return undefined\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity>(entities: Entity[], options?: SaveOptions): Promise<Entity[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Saves a given entity in the database.\n */\n save<Entity extends ObjectLiteral, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute save operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"save\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(entity: Entity, options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n entity: Entity,\n options?: RemoveOptions,\n ): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(entity: Entity[], options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n entity: Entity[],\n options?: RemoveOptions,\n ): Promise<Entity[]>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity extends ObjectLiteral>(\n targetOrEntity: (Entity | Entity[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: Entity | Entity[],\n maybeOptions?: RemoveOptions,\n ): Promise<Entity | Entity[]> {\n // normalize mixed parameters\n const target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: Entity | Entity[] = target\n ? (maybeEntityOrOptions as Entity | Entity[])\n : (targetOrEntity as Entity | Entity[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute save operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"remove\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<Entity>(\n entities: Entity[],\n options?: SaveOptions,\n ): Promise<Entity[]>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<Entity extends ObjectLiteral, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute soft-remove operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"soft-remove\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Recovers all given entities.\n */\n recover<Entity>(\n entities: Entity[],\n options?: SaveOptions,\n ): Promise<Entity[]>\n\n /**\n * Recovers a given entity.\n */\n recover<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Recovers all given entities.\n */\n recover<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Recovers a given entity.\n */\n recover<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Recovers one or many given entities.\n */\n recover<Entity extends ObjectLiteral, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute recover operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"recover\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n * You can execute bulk inserts using this method.\n */\n async insert<Entity>(\n target: EntityTarget<Entity>,\n entity:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n ): Promise<InsertResult> {\n return this.createQueryBuilder()\n .insert()\n .into(target)\n .values(entity)\n .execute()\n }\n\n async upsert<Entity>(\n target: EntityTarget<Entity>,\n entityOrEntities:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>,\n ): Promise<InsertResult> {\n const metadata = this.connection.getMetadata(target)\n\n let options: UpsertOptions<Entity>\n\n if (Array.isArray(conflictPathsOrOptions)) {\n options = {\n conflictPaths: conflictPathsOrOptions,\n }\n } else {\n options = conflictPathsOrOptions\n }\n\n let entities: QueryDeepPartialEntity<Entity>[]\n\n if (!Array.isArray(entityOrEntities)) {\n entities = [entityOrEntities]\n } else {\n entities = entityOrEntities\n }\n\n const conflictColumns = metadata.mapPropertyPathsToColumns(\n options.conflictPaths,\n )\n\n const overwriteColumns = metadata.columns.filter(\n (col) =>\n !conflictColumns.includes(col) &&\n entities.some(\n (entity) =>\n typeof col.getEntityValue(entity) !== \"undefined\",\n ),\n )\n\n return this.createQueryBuilder()\n .insert()\n .into(target)\n .values(entities)\n .orUpdate(\n [...conflictColumns, ...overwriteColumns].map(\n (col) => col.databaseName,\n ),\n conflictColumns.map((col) => col.databaseName),\n {\n skipUpdateIfNoValuesChanged:\n options.skipUpdateIfNoValuesChanged,\n },\n )\n .execute()\n }\n\n /**\n * Updates entity partially. Entity can be found by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n update<Entity>(\n target: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n partialEntity: QueryDeepPartialEntity<Entity>,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the update method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Deletes entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n delete<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<DeleteResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .delete()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .delete()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Records the delete date of entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n softDelete<Entity extends ObjectLiteral>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .softDelete()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .softDelete()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Restores entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n restore<Entity extends ObjectLiteral>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .restore()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .restore()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Counts entities that match given options.\n * Useful for pagination.\n */\n count<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<number> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(\n entityClass,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getCount()\n }\n\n /**\n * Counts entities that match given conditions.\n * Useful for pagination.\n */\n countBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(entityClass, metadata.name)\n .setFindOptions({ where })\n .getCount()\n }\n\n /**\n * Finds entities that match given find options.\n */\n async find<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<Entity[]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getMany()\n }\n\n /**\n * Finds entities that match given find options.\n */\n async findBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity[]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .setFindOptions({ where: where })\n .getMany()\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getManyAndCount()\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<[Entity[], number]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .setFindOptions({ where })\n .getManyAndCount()\n }\n\n /**\n * Finds entities with ids.\n * Optionally find options or conditions can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n async findByIds<Entity>(\n entityClass: EntityTarget<Entity>,\n ids: any[],\n ): Promise<Entity[]> {\n // if no ids passed, no need to execute a query - just return an empty array of values\n if (!ids.length) return Promise.resolve([])\n\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .andWhereInIds(ids)\n .getMany()\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - returns null.\n */\n async findOne<Entity>(\n entityClass: EntityTarget<Entity>,\n options: FindOneOptions<Entity>,\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // prepare alias for built query\n let alias: string = metadata.name\n if (options && options.join) {\n alias = options.join.alias\n }\n\n if (!options.where) {\n throw new Error(\n `You must provide selection conditions in order to find a single row.`,\n )\n }\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, alias)\n .setFindOptions({\n ...options,\n take: 1,\n })\n .getOne()\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - returns null.\n */\n async findOneBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, metadata.name)\n .setFindOptions({\n where,\n take: 1,\n })\n .getOne()\n }\n\n /**\n * Finds first entity that matches given id.\n * If entity was not found in the database - returns null.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById<Entity>(\n entityClass: EntityTarget<Entity>,\n id: number | string | Date | ObjectID,\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, metadata.name)\n .setFindOptions({\n take: 1,\n })\n .whereInIds(metadata.ensureEntityIdMap(id))\n .getOne()\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail<Entity>(\n entityClass: EntityTarget<Entity>,\n options: FindOneOptions<Entity>,\n ): Promise<Entity> {\n return this.findOne<Entity>(entityClass as any, options).then(\n (value) => {\n if (value === null) {\n return Promise.reject(\n new EntityNotFoundError(entityClass, options),\n )\n }\n return Promise.resolve(value)\n },\n )\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity> {\n return this.findOneBy<Entity>(entityClass as any, where).then(\n (value) => {\n if (value === null) {\n return Promise.reject(\n new EntityNotFoundError(entityClass, where),\n )\n }\n return Promise.resolve(value)\n },\n )\n }\n\n /**\n * Clears all the data from the given table (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n async clear<Entity>(entityClass: EntityTarget<Entity>): Promise<void> {\n const metadata = this.connection.getMetadata(entityClass)\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n try {\n return await queryRunner.clearTable(metadata.tablePath) // await is needed here because we are using finally\n } finally {\n if (!this.queryRunner) await queryRunner.release()\n }\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n async increment<Entity>(\n entityClass: EntityTarget<Entity>,\n conditions: any,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.findColumnWithPropertyPath(propertyPath)\n if (!column)\n throw new TypeORMError(\n `Column ${propertyPath} was not found in ${metadata.targetName} entity.`,\n )\n\n if (isNaN(Number(value)))\n throw new TypeORMError(`Value \"${value}\" is not a number.`)\n\n // convert possible embeded path \"social.likes\" into object { social: { like: () => value } }\n const values: QueryDeepPartialEntity<Entity> = propertyPath\n .split(\".\")\n .reduceRight(\n (value, key) => ({ [key]: value } as any),\n () =>\n this.connection.driver.escape(column.databaseName) +\n \" + \" +\n value,\n )\n\n return this.createQueryBuilder<Entity>(entityClass as any, \"entity\")\n .update(entityClass)\n .set(values)\n .where(conditions)\n .execute()\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n async decrement<Entity>(\n entityClass: EntityTarget<Entity>,\n conditions: any,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.findColumnWithPropertyPath(propertyPath)\n if (!column)\n throw new TypeORMError(\n `Column ${propertyPath} was not found in ${metadata.targetName} entity.`,\n )\n\n if (isNaN(Number(value)))\n throw new TypeORMError(`Value \"${value}\" is not a number.`)\n\n // convert possible embeded path \"social.likes\" into object { social: { like: () => value } }\n const values: QueryDeepPartialEntity<Entity> = propertyPath\n .split(\".\")\n .reduceRight(\n (value, key) => ({ [key]: value } as any),\n () =>\n this.connection.driver.escape(column.databaseName) +\n \" - \" +\n value,\n )\n\n return this.createQueryBuilder<Entity>(entityClass as any, \"entity\")\n .update(entityClass)\n .set(values)\n .where(conditions)\n .execute()\n }\n\n /**\n * Gets repository for the given entity class or name.\n * If single database connection mode is used, then repository is obtained from the\n * repository aggregator, where each repository is individually created for this entity manager.\n * When single database connection is not used, repository is being obtained from the connection.\n */\n getRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): Repository<Entity> {\n // find already created repository instance and return it if found\n const repository = this.repositories.find(\n (repository) => repository.target === target,\n )\n if (repository) return repository\n\n // if repository was not found then create it, store its instance and return it\n if (this.connection.driver.options.type === \"mongodb\") {\n const newRepository = new MongoRepository(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.push(newRepository as any)\n return newRepository\n } else {\n const newRepository = new Repository<any>(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.push(newRepository)\n return newRepository\n }\n }\n\n /**\n * Gets tree repository for the given entity class or name.\n * If single database connection mode is used, then repository is obtained from the\n * repository aggregator, where each repository is individually created for this entity manager.\n * When single database connection is not used, repository is being obtained from the connection.\n */\n getTreeRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): TreeRepository<Entity> {\n // tree tables aren't supported by some drivers (mongodb)\n if (this.connection.driver.treeSupport === false)\n throw new TreeRepositoryNotSupportedError(this.connection.driver)\n\n // find already created repository instance and return it if found\n const repository = this.treeRepositories.find(\n (repository) => repository.target === target,\n )\n if (repository) return repository\n\n // check if repository is real tree repository\n const newRepository = new TreeRepository(target, this, this.queryRunner)\n this.treeRepositories.push(newRepository)\n return newRepository\n }\n\n /**\n * Gets mongodb repository for the given entity class.\n */\n getMongoRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): MongoRepository<Entity> {\n return this.connection.getMongoRepository<Entity>(target)\n }\n\n /**\n * Creates a new repository instance out of a given Repository and\n * sets current EntityManager instance to it. Used to work with custom repositories\n * in transactions.\n */\n withRepository<Entity extends ObjectLiteral, R extends Repository<Entity>>(\n repository: R,\n ): R {\n const repositoryConstructor =\n repository.constructor as typeof Repository\n const { target, manager, queryRunner, ...otherRepositoryProperties } =\n repository\n return Object.assign(\n new repositoryConstructor(repository.target, this) as R,\n {\n ...otherRepositoryProperties,\n },\n )\n }\n\n /**\n * Gets custom entity repository marked with @EntityRepository decorator.\n *\n * @deprecated use Repository.extend to create custom repositories\n */\n getCustomRepository<T>(customRepository: ObjectType<T>): T {\n const entityRepositoryMetadataArgs =\n getMetadataArgsStorage().entityRepositories.find((repository) => {\n return (\n repository.target ===\n (typeof customRepository === \"function\"\n ? customRepository\n : (customRepository as any).constructor)\n )\n })\n if (!entityRepositoryMetadataArgs)\n throw new CustomRepositoryNotFoundError(customRepository)\n\n const entityMetadata = entityRepositoryMetadataArgs.entity\n ? this.connection.getMetadata(entityRepositoryMetadataArgs.entity)\n : undefined\n const entityRepositoryInstance =\n new (entityRepositoryMetadataArgs.target as any)(\n this,\n entityMetadata,\n )\n\n // NOTE: dynamic access to protected properties. We need this to prevent unwanted properties in those classes to be exposed,\n // however we need these properties for internal work of the class\n if (entityRepositoryInstance instanceof AbstractRepository) {\n if (!(entityRepositoryInstance as any)[\"manager\"])\n (entityRepositoryInstance as any)[\"manager\"] = this\n } else {\n if (!entityMetadata)\n throw new CustomRepositoryCannotInheritRepositoryError(\n customRepository,\n )\n ;(entityRepositoryInstance as any)[\"manager\"] = this\n ;(entityRepositoryInstance as any)[\"metadata\"] = entityMetadata\n }\n\n return entityRepositoryInstance\n }\n\n /**\n * Releases all resources used by entity manager.\n * This is used when entity manager is created with a single query runner,\n * and this single query runner needs to be released after job with entity manager is done.\n */\n async release(): Promise<void> {\n if (!this.queryRunner) throw new NoNeedToReleaseEntityManagerError()\n\n return this.queryRunner.release()\n }\n}\n"],"sourceRoot":".."}
|