typeorm 0.3.25-dev.65d5a00 → 0.3.25-dev.930eefd

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/README.md CHANGED
@@ -29,7 +29,7 @@ that help you to develop any kind of application that uses databases - from
29
29
  small applications with a few tables to large-scale enterprise applications
30
30
  with multiple databases.
31
31
 
32
- TypeORM supports both [Active Record](./docs/active-record-data-mapper.md#what-is-the-active-record-pattern) and [Data Mapper](./docs/active-record-data-mapper.md#what-is-the-data-mapper-pattern) patterns,
32
+ TypeORM supports both [Active Record](./docs/docs/guides/1-active-record-data-mapper.md#what-is-the-active-record-pattern) and [Data Mapper](./docs/docs/guides/1-active-record-data-mapper.md#what-is-the-data-mapper-pattern) patterns,
33
33
  unlike all other JavaScript ORMs currently in existence,
34
34
  which means you can write high-quality, loosely coupled, scalable,
35
35
  maintainable applications in the most productive way.
@@ -39,7 +39,7 @@ TypeORM is highly influenced by other ORMs, such as [Hibernate](http://hibernate
39
39
 
40
40
  ## Features
41
41
 
42
- - Supports both [DataMapper](./docs/active-record-data-mapper.md#what-is-the-data-mapper-pattern) and [ActiveRecord](./docs/active-record-data-mapper.md#what-is-the-active-record-pattern) (your choice).
42
+ - Supports both [DataMapper](./docs/docs/guides/1-active-record-data-mapper.md#what-is-the-data-mapper-pattern) and [ActiveRecord](./docs/docs/guides/1-active-record-data-mapper.md#what-is-the-active-record-pattern) (your choice).
43
43
  - Entities and columns.
44
44
  - Database-specific column types.
45
45
  - Entity manager.
@@ -158,7 +158,7 @@ const firstUser = await User.findOneBy({
158
158
  })
159
159
  const timber = await User.findOneBy({
160
160
  firstName: "Timber",
161
- lastName: "Saw"
161
+ lastName: "Saw",
162
162
  })
163
163
 
164
164
  await timber.remove()
@@ -255,7 +255,7 @@ await timber.remove()
255
255
 
256
256
  - for **NativeScript**, **react-native** and **Cordova**
257
257
 
258
- Check [documentation of supported platforms](./docs/supported-platforms.md)
258
+ Check [documentation of supported platforms](./docs/docs/help/2-supported-platforms.md)
259
259
 
260
260
  Install only _one_ of them, depending on which database you use.
261
261
 
@@ -547,7 +547,7 @@ export class Photo {
547
547
 
548
548
  Column types are database-specific.
549
549
  You can set any column type your database supports.
550
- More information on supported column types can be found [here](./docs/entities.md#column-types).
550
+ More information on supported column types can be found [here](./docs/docs/entity/1-entities.md#column-types).
551
551
 
552
552
  ### Creating a new `DataSource`
553
553
 
@@ -648,7 +648,7 @@ console.log("All photos from the db: ", savedPhotos)
648
648
 
649
649
  `savedPhotos` will be an array of Photo objects with the data loaded from the database.
650
650
 
651
- Learn more about EntityManager [here](./docs/working-with-entity-manager.md).
651
+ Learn more about EntityManager [here](./docs/docs/working-with-entity-manager/1-working-with-entity-manager.md).
652
652
 
653
653
  ### Using Repositories
654
654
 
@@ -676,7 +676,7 @@ const savedPhotos = await photoRepository.find()
676
676
  console.log("All photos from the db: ", savedPhotos)
677
677
  ```
678
678
 
679
- Learn more about Repository [here](./docs/working-with-repository.md).
679
+ Learn more about Repository [here](./docs/docs/working-with-entity-manager/2-working-with-repository.md).
680
680
 
681
681
  ### Loading from the database
682
682
 
@@ -966,7 +966,7 @@ const photos = await photoRepository.find({
966
966
  ```
967
967
 
968
968
  Here, photos will contain an array of photos from the database, and each photo will contain its photo metadata.
969
- Learn more about Find Options in [this documentation](./docs/find-options.md).
969
+ Learn more about Find Options in [this documentation](./docs/docs/working-with-entity-manager/3-find-options.md).
970
970
 
971
971
  Using find options is good and dead simple, but if you need a more complex query, you should use `QueryBuilder` instead.
972
972
  `QueryBuilder` allows more complex queries to be used in an elegant way:
@@ -1255,7 +1255,7 @@ The selection result will be ordered by id in descending order.
1255
1255
  The photo albums will be left joined and their metadata will be inner joined.
1256
1256
 
1257
1257
  You'll use the query builder in your application a lot.
1258
- Learn more about QueryBuilder [here](./docs/select-query-builder.md).
1258
+ Learn more about QueryBuilder [here](./docs/docs/query-builder/1-select-query-builder.md).
1259
1259
 
1260
1260
  ## Samples
1261
1261
 
@@ -64,7 +64,7 @@ export declare class EntityManager {
64
64
  /**
65
65
  * Executes raw SQL query and returns raw database results.
66
66
  *
67
- * @see [Official docs](https://typeorm.io/entity-manager-api) for examples.
67
+ * @see [Official docs](https://typeorm.io/docs/Working%20with%20Entity%20Manager/entity-manager-api/) for examples.
68
68
  */
69
69
  query<T = any>(query: string, parameters?: any[]): Promise<T>;
70
70
  /**
@@ -90,7 +90,7 @@ export class EntityManager {
90
90
  /**
91
91
  * Executes raw SQL query and returns raw database results.
92
92
  *
93
- * @see [Official docs](https://typeorm.io/entity-manager-api) for examples.
93
+ * @see [Official docs](https://typeorm.io/docs/Working%20with%20Entity%20Manager/entity-manager-api/) for examples.
94
94
  */
95
95
  async query(query, parameters) {
96
96
  return this.connection.query(query, parameters, this.queryRunner);
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/entity-manager/EntityManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,kDAAkD,CAAA;AAK1G,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAA;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,gEAAgE,CAAA;AAClH,OAAO,EAAE,sCAAsC,EAAE,MAAM,qEAAqE,CAAA;AAC5H,OAAO,EACH,4CAA4C,EAC5C,6BAA6B,EAC7B,+BAA+B,EAC/B,YAAY,GACf,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAIrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;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U,EAAE,EAAE;YAC5D,OAAO,CACH,UAAU,CAAC,MAAM;gBACjB,CAAC,OAAO,gBAAgB,KAAK,UAAU;oBACnC,CAAC,CAAC,gBAAgB;oBAClB,CAAC,CAAE,gBAAwB,CAAC,WAAW,CAAC,CAC/C,CAAA;QACL,CAAC,CAAC,CAAA;QACN,IAAI,CAAC,4BAA4B;YAC7B,MAAM,IAAI,6BAA6B,CAAC,gBAAgB,CAAC,CAAA;QAE7D,MAAM,cAAc,GAAG,4BAA4B,CAAC,MAAM;YACtD,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,4BAA4B,CAAC,MAAM,CAAC;YAClE,CAAC,CAAC,SAAS,CAAA;QACf,MAAM,wBAAwB,GAC1B,IAAK,4BAA4B,CAAC,MAAc,CAC5C,IAAI,EACJ,cAAc,CACjB,CAAA;QAEL,4HAA4H;QAC5H,kEAAkE;QAClE,IAAI,wBAAwB,YAAY,kBAAkB,EAAE,CAAC;YACzD,IAAI,CAAE,wBAAgC,CAAC,SAAS,CAAC;gBAC5C,wBAAgC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAA;QAC3D,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,cAAc;gBACf,MAAM,IAAI,4CAA4C,CAClD,gBAAgB,CACnB,CACJ;YAAC,wBAAgC,CAAC,SAAS,CAAC,GAAG,IAAI,CACnD;YAAC,wBAAgC,CAAC,UAAU,CAAC,GAAG,cAAc,CAAA;QACnE,CAAC;QAED,OAAO,wBAAwB,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,iCAAiC,EAAE,CAAA;QAEpE,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;IACrC,CAAC;CACJ","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\"\nimport { PickKeysByType } from \"../common/PickKeysByType\"\nimport { buildSqlTag } from \"../util/SqlTagUtils\"\nimport { OrmUtils } from \"../util/OrmUtils\"\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 * Created as a future replacement for the #repositories to provide a bit more perf optimization.\n */\n protected repositories = new Map<EntityTarget<any>, 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 * @see [Official docs](https://typeorm.io/entity-manager-api) for examples.\n */\n async query<T = any>(query: string, parameters?: any[]): Promise<T> {\n return this.connection.query(query, parameters, this.queryRunner)\n }\n\n /**\n * Tagged template function that executes raw SQL query and returns raw database results.\n * Template expressions are automatically transformed into database parameters.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n * Note: Don't call this as a regular function, it is meant to be used with backticks to tag a template literal.\n * Example: entityManager.sql`SELECT * FROM table_name WHERE id = ${id}`\n */\n async sql<T = any>(\n strings: TemplateStringsArray,\n ...values: unknown[]\n ): Promise<T> {\n const { query, parameters } = buildSqlTag({\n driver: this.connection.driver,\n strings: strings,\n expressions: values,\n })\n\n return await this.query(query, parameters)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity extends ObjectLiteral>(\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 extends ObjectLiteral>(\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, EntityLike extends DeepPartial<Entity>>(\n entityClass: EntityTarget<Entity>,\n plainObject?: EntityLike,\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, EntityLike extends DeepPartial<Entity>>(\n entityClass: EntityTarget<Entity>,\n plainObjects?: EntityLike[],\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, EntityLike extends DeepPartial<Entity>>(\n entityClass: EntityTarget<Entity>,\n plainObjectOrObjects?: EntityLike | EntityLike[],\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 EntityLike[]).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 InstanceChecker.isEntitySchema(targetOrEntity) ||\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 Array.isArray(options.conflictPaths)\n ? options.conflictPaths\n : Object.keys(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 indexPredicate: options.indexPredicate,\n upsertType:\n options.upsertType ||\n this.connection.driver.supportedUpsertTypes[0],\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 extends ObjectLiteral>(\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 (OrmUtils.isCriteriaNullOrEmpty(criteria)) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the update method.`,\n ),\n )\n }\n\n if (OrmUtils.isPrimitiveCriteria(criteria)) {\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 * Updates all entities of target type, setting fields from supplied partial entity.\n * This is a primitive operation without cascades, relations or other operations included.\n * Executes fast and efficient UPDATE query without WHERE clause.\n *\n * WARNING! This method updates ALL rows in the target table.\n */\n updateAll<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n partialEntity: QueryDeepPartialEntity<Entity>,\n ): Promise<UpdateResult> {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .execute()\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 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<DeleteResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (OrmUtils.isCriteriaNullOrEmpty(criteria)) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (OrmUtils.isPrimitiveCriteria(criteria)) {\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 * Deletes all entities of target type.\n * This is a primitive operation without cascades, relations or other operations included.\n * Executes fast and efficient DELETE query without WHERE clause.\n *\n * WARNING! This method deletes ALL rows in the target table.\n */\n deleteAll<Entity extends ObjectLiteral>(\n targetOrEntity: EntityTarget<Entity>,\n ): Promise<DeleteResult> {\n return this.createQueryBuilder().delete().from(targetOrEntity).execute()\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 UPDATE 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 (OrmUtils.isCriteriaNullOrEmpty(criteria)) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the softDelete method.`,\n ),\n )\n }\n\n if (OrmUtils.isPrimitiveCriteria(criteria)) {\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 UPDATE 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 (OrmUtils.isCriteriaNullOrEmpty(criteria)) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the restore method.`,\n ),\n )\n }\n\n if (OrmUtils.isPrimitiveCriteria(criteria)) {\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 * Checks whether any entity exists with the given options.\n */\n exists<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<boolean> {\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 .getExists()\n }\n\n /**\n * Checks whether any entity exists with the given conditions.\n */\n async existsBy<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<boolean> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(entityClass, metadata.name)\n .setFindOptions({ where })\n .getExists()\n }\n\n /**\n * Counts entities that match given options.\n * Useful for pagination.\n */\n count<Entity extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 * Return the SUM of a column\n */\n sum<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.callAggregateFun(entityClass, \"SUM\", columnName, where)\n }\n\n /**\n * Return the AVG of a column\n */\n average<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.callAggregateFun(entityClass, \"AVG\", columnName, where)\n }\n\n /**\n * Return the MIN of a column\n */\n minimum<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.callAggregateFun(entityClass, \"MIN\", columnName, where)\n }\n\n /**\n * Return the MAX of a column\n */\n maximum<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.callAggregateFun(entityClass, \"MAX\", columnName, where)\n }\n\n private async callAggregateFun<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n fnName: \"SUM\" | \"AVG\" | \"MIN\" | \"MAX\",\n columnName: PickKeysByType<Entity, number>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[] = {},\n ): Promise<number | null> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.columns.find(\n (item) => item.propertyPath === columnName,\n )\n if (!column) {\n throw new TypeORMError(\n `Column \"${columnName}\" was not found in table \"${metadata.name}\"`,\n )\n }\n\n const result = await this.createQueryBuilder(entityClass, metadata.name)\n .setFindOptions({ where })\n .select(\n `${fnName}(${this.connection.driver.escape(\n column.databaseName,\n )})`,\n fnName,\n )\n .getRawOne()\n return result[fnName] === null ? null : parseFloat(result[fnName])\n }\n\n /**\n * Finds entities that match given find options.\n */\n async find<Entity extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 embedded 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 extends ObjectLiteral>(\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 embedded 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 repoFromMap = this.repositories.get(target)\n if (repoFromMap) return repoFromMap\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.set(target, newRepository)\n return newRepository\n } else {\n const newRepository = new Repository<any>(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.set(target, 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<any>>(\n repository: R & Repository<Entity>,\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":".."}
1
+ {"version":3,"sources":["../browser/src/entity-manager/EntityManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,kDAAkD,CAAA;AAK1G,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAA;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,gEAAgE,CAAA;AAClH,OAAO,EAAE,sCAAsC,EAAE,MAAM,qEAAqE,CAAA;AAC5H,OAAO,EACH,4CAA4C,EAC5C,6BAA6B,EAC7B,+BAA+B,EAC/B,YAAY,GACf,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,kBA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.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\"\nimport { PickKeysByType } from \"../common/PickKeysByType\"\nimport { buildSqlTag } from \"../util/SqlTagUtils\"\nimport { OrmUtils } from \"../util/OrmUtils\"\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 * Created as a future replacement for the #repositories to provide a bit more perf optimization.\n */\n protected repositories = new Map<EntityTarget<any>, 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 * @see [Official docs](https://typeorm.io/docs/Working%20with%20Entity%20Manager/entity-manager-api/) for examples.\n */\n async query<T = any>(query: string, parameters?: any[]): Promise<T> {\n return this.connection.query(query, parameters, this.queryRunner)\n }\n\n /**\n * Tagged template function that executes raw SQL query and returns raw database results.\n * Template expressions are automatically transformed into database parameters.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n * Note: Don't call this as a regular function, it is meant to be used with backticks to tag a template literal.\n * Example: entityManager.sql`SELECT * FROM table_name WHERE id = ${id}`\n */\n async sql<T = any>(\n strings: TemplateStringsArray,\n ...values: unknown[]\n ): Promise<T> {\n const { query, parameters } = buildSqlTag({\n driver: this.connection.driver,\n strings: strings,\n expressions: values,\n })\n\n return await this.query(query, parameters)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity extends ObjectLiteral>(\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 extends ObjectLiteral>(\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, EntityLike extends DeepPartial<Entity>>(\n entityClass: EntityTarget<Entity>,\n plainObject?: EntityLike,\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, EntityLike extends DeepPartial<Entity>>(\n entityClass: EntityTarget<Entity>,\n plainObjects?: EntityLike[],\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, EntityLike extends DeepPartial<Entity>>(\n entityClass: EntityTarget<Entity>,\n plainObjectOrObjects?: EntityLike | EntityLike[],\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 EntityLike[]).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 InstanceChecker.isEntitySchema(targetOrEntity) ||\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 Array.isArray(options.conflictPaths)\n ? options.conflictPaths\n : Object.keys(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 indexPredicate: options.indexPredicate,\n upsertType:\n options.upsertType ||\n this.connection.driver.supportedUpsertTypes[0],\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 extends ObjectLiteral>(\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 (OrmUtils.isCriteriaNullOrEmpty(criteria)) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the update method.`,\n ),\n )\n }\n\n if (OrmUtils.isPrimitiveCriteria(criteria)) {\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 * Updates all entities of target type, setting fields from supplied partial entity.\n * This is a primitive operation without cascades, relations or other operations included.\n * Executes fast and efficient UPDATE query without WHERE clause.\n *\n * WARNING! This method updates ALL rows in the target table.\n */\n updateAll<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n partialEntity: QueryDeepPartialEntity<Entity>,\n ): Promise<UpdateResult> {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .execute()\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 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<DeleteResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (OrmUtils.isCriteriaNullOrEmpty(criteria)) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (OrmUtils.isPrimitiveCriteria(criteria)) {\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 * Deletes all entities of target type.\n * This is a primitive operation without cascades, relations or other operations included.\n * Executes fast and efficient DELETE query without WHERE clause.\n *\n * WARNING! This method deletes ALL rows in the target table.\n */\n deleteAll<Entity extends ObjectLiteral>(\n targetOrEntity: EntityTarget<Entity>,\n ): Promise<DeleteResult> {\n return this.createQueryBuilder().delete().from(targetOrEntity).execute()\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 UPDATE 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 (OrmUtils.isCriteriaNullOrEmpty(criteria)) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the softDelete method.`,\n ),\n )\n }\n\n if (OrmUtils.isPrimitiveCriteria(criteria)) {\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 UPDATE 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 (OrmUtils.isCriteriaNullOrEmpty(criteria)) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the restore method.`,\n ),\n )\n }\n\n if (OrmUtils.isPrimitiveCriteria(criteria)) {\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 * Checks whether any entity exists with the given options.\n */\n exists<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<boolean> {\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 .getExists()\n }\n\n /**\n * Checks whether any entity exists with the given conditions.\n */\n async existsBy<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<boolean> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(entityClass, metadata.name)\n .setFindOptions({ where })\n .getExists()\n }\n\n /**\n * Counts entities that match given options.\n * Useful for pagination.\n */\n count<Entity extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 * Return the SUM of a column\n */\n sum<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.callAggregateFun(entityClass, \"SUM\", columnName, where)\n }\n\n /**\n * Return the AVG of a column\n */\n average<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.callAggregateFun(entityClass, \"AVG\", columnName, where)\n }\n\n /**\n * Return the MIN of a column\n */\n minimum<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.callAggregateFun(entityClass, \"MIN\", columnName, where)\n }\n\n /**\n * Return the MAX of a column\n */\n maximum<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.callAggregateFun(entityClass, \"MAX\", columnName, where)\n }\n\n private async callAggregateFun<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n fnName: \"SUM\" | \"AVG\" | \"MIN\" | \"MAX\",\n columnName: PickKeysByType<Entity, number>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[] = {},\n ): Promise<number | null> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.columns.find(\n (item) => item.propertyPath === columnName,\n )\n if (!column) {\n throw new TypeORMError(\n `Column \"${columnName}\" was not found in table \"${metadata.name}\"`,\n )\n }\n\n const result = await this.createQueryBuilder(entityClass, metadata.name)\n .setFindOptions({ where })\n .select(\n `${fnName}(${this.connection.driver.escape(\n column.databaseName,\n )})`,\n fnName,\n )\n .getRawOne()\n return result[fnName] === null ? null : parseFloat(result[fnName])\n }\n\n /**\n * Finds entities that match given find options.\n */\n async find<Entity extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 extends ObjectLiteral>(\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 embedded 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 extends ObjectLiteral>(\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 embedded 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 repoFromMap = this.repositories.get(target)\n if (repoFromMap) return repoFromMap\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.set(target, newRepository)\n return newRepository\n } else {\n const newRepository = new Repository<any>(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.set(target, 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<any>>(\n repository: R & Repository<Entity>,\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":".."}
@@ -4,7 +4,7 @@ import { TypeORMError } from "./TypeORMError";
4
4
  * Thrown when relation has array initialized which is forbidden my ORM.
5
5
  *
6
6
  * @see https://github.com/typeorm/typeorm/issues/1319
7
- * @see http://typeorm.io/#/relations-faq/avoid-relation-property-initializers
7
+ * @see http://typeorm.io/docs/Relations/relations-faq/#avoid-relation-property-initializers
8
8
  */
9
9
  export declare class InitializedRelationError extends TypeORMError {
10
10
  constructor(relation: RelationMetadata);
@@ -3,7 +3,7 @@ import { TypeORMError } from "./TypeORMError";
3
3
  * Thrown when relation has array initialized which is forbidden my ORM.
4
4
  *
5
5
  * @see https://github.com/typeorm/typeorm/issues/1319
6
- * @see http://typeorm.io/#/relations-faq/avoid-relation-property-initializers
6
+ * @see http://typeorm.io/docs/Relations/relations-faq/#avoid-relation-property-initializers
7
7
  */
8
8
  export class InitializedRelationError extends TypeORMError {
9
9
  constructor(relation) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/error/InitializedRelationError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,YAAY;IACtD,YAAY,QAA0B;QAClC,KAAK,CACD,6DAA6D;YACzD,mDAAmD,QAAQ,CAAC,cAAc,CAAC,UAAU,IAAI,QAAQ,CAAC,YAAY,KAAK;YACnH,8FAA8F,CACrG,CAAA;IACL,CAAC;CACJ","file":"InitializedRelationError.js","sourcesContent":["import { RelationMetadata } from \"../metadata/RelationMetadata\"\nimport { TypeORMError } from \"./TypeORMError\"\n\n/**\n * Thrown when relation has array initialized which is forbidden my ORM.\n *\n * @see https://github.com/typeorm/typeorm/issues/1319\n * @see http://typeorm.io/#/relations-faq/avoid-relation-property-initializers\n */\nexport class InitializedRelationError extends TypeORMError {\n constructor(relation: RelationMetadata) {\n super(\n `Array initializations are not allowed in entity relations. ` +\n `Please remove array initialization (= []) from \"${relation.entityMetadata.targetName}#${relation.propertyPath}\". ` +\n `This is ORM requirement to make relations to work properly. Refer docs for more information.`,\n )\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/error/InitializedRelationError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,YAAY;IACtD,YAAY,QAA0B;QAClC,KAAK,CACD,6DAA6D;YACzD,mDAAmD,QAAQ,CAAC,cAAc,CAAC,UAAU,IAAI,QAAQ,CAAC,YAAY,KAAK;YACnH,8FAA8F,CACrG,CAAA;IACL,CAAC;CACJ","file":"InitializedRelationError.js","sourcesContent":["import { RelationMetadata } from \"../metadata/RelationMetadata\"\nimport { TypeORMError } from \"./TypeORMError\"\n\n/**\n * Thrown when relation has array initialized which is forbidden my ORM.\n *\n * @see https://github.com/typeorm/typeorm/issues/1319\n * @see http://typeorm.io/docs/Relations/relations-faq/#avoid-relation-property-initializers\n */\nexport class InitializedRelationError extends TypeORMError {\n constructor(relation: RelationMetadata) {\n super(\n `Array initializations are not allowed in entity relations. ` +\n `Please remove array initialization (= []) from \"${relation.entityMetadata.targetName}#${relation.propertyPath}\". ` +\n `This is ORM requirement to make relations to work properly. Refer docs for more information.`,\n )\n }\n}\n"],"sourceRoot":".."}
@@ -186,13 +186,13 @@ export declare class ColumnMetadata {
186
186
  /**
187
187
  * Indicates if column is a virtual property. Virtual properties are not mapped to the entity.
188
188
  * This property is used in tandem the virtual column decorator.
189
- * @See https://typeorm.io/decorator-reference#virtualcolumn for more details.
189
+ * @See https://typeorm.io/docs/Help/decorator-reference/#virtualcolumn for more details.
190
190
  */
191
191
  isVirtualProperty: boolean;
192
192
  /**
193
193
  * Query to be used to populate the column data. This query is used when generating the relational db script.
194
194
  * The query function is called with the current entities alias either defined by the Entity Decorator or automatically
195
- * @See https://typeorm.io/decorator-reference#virtualcolumn for more details.
195
+ * @See https://typeorm.io/docs/Help/decorator-reference/#virtualcolumn for more details.
196
196
  */
197
197
  query?: (alias: string) => string;
198
198
  /**
@@ -59,7 +59,7 @@ export class ColumnMetadata {
59
59
  /**
60
60
  * Indicates if column is a virtual property. Virtual properties are not mapped to the entity.
61
61
  * This property is used in tandem the virtual column decorator.
62
- * @See https://typeorm.io/decorator-reference#virtualcolumn for more details.
62
+ * @See https://typeorm.io/docs/Help/decorator-reference/#virtualcolumn for more details.
63
63
  */
64
64
  this.isVirtualProperty = false;
65
65
  /**