typeorm 0.3.8-dev.dadb658 → 0.3.8-dev.de8aaac

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.
Files changed (43) hide show
  1. package/browser/driver/postgres/PostgresQueryRunner.d.ts +1 -1
  2. package/browser/driver/postgres/PostgresQueryRunner.js +10 -16
  3. package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
  4. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +1 -1
  5. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +9 -13
  6. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  7. package/browser/driver/sqlserver/SqlServerConnectionOptions.d.ts +1 -6
  8. package/browser/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  9. package/browser/entity-manager/EntityManager.js +0 -1
  10. package/browser/entity-manager/EntityManager.js.map +1 -1
  11. package/browser/entity-manager/MongoEntityManager.d.ts +1 -1
  12. package/browser/entity-manager/MongoEntityManager.js +10 -17
  13. package/browser/entity-manager/MongoEntityManager.js.map +1 -1
  14. package/browser/persistence/SubjectTopoligicalSorter.js +1 -5
  15. package/browser/persistence/SubjectTopoligicalSorter.js.map +1 -1
  16. package/browser/query-builder/SelectQueryBuilder.d.ts +0 -6
  17. package/browser/query-builder/SelectQueryBuilder.js +3 -6
  18. package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
  19. package/browser/util/DateUtils.d.ts +1 -1
  20. package/browser/util/DateUtils.js +8 -7
  21. package/browser/util/DateUtils.js.map +1 -1
  22. package/driver/postgres/PostgresQueryRunner.d.ts +1 -1
  23. package/driver/postgres/PostgresQueryRunner.js +10 -16
  24. package/driver/postgres/PostgresQueryRunner.js.map +1 -1
  25. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +1 -1
  26. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +9 -13
  27. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  28. package/driver/sqlserver/SqlServerConnectionOptions.d.ts +1 -6
  29. package/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  30. package/entity-manager/EntityManager.js +0 -1
  31. package/entity-manager/EntityManager.js.map +1 -1
  32. package/entity-manager/MongoEntityManager.d.ts +1 -1
  33. package/entity-manager/MongoEntityManager.js +10 -17
  34. package/entity-manager/MongoEntityManager.js.map +1 -1
  35. package/package.json +1 -1
  36. package/persistence/SubjectTopoligicalSorter.js +1 -5
  37. package/persistence/SubjectTopoligicalSorter.js.map +1 -1
  38. package/query-builder/SelectQueryBuilder.d.ts +0 -6
  39. package/query-builder/SelectQueryBuilder.js +3 -6
  40. package/query-builder/SelectQueryBuilder.js.map +1 -1
  41. package/util/DateUtils.d.ts +1 -1
  42. package/util/DateUtils.js +8 -7
  43. package/util/DateUtils.js.map +1 -1
@@ -186,7 +186,7 @@ export interface SqlServerConnectionOptions extends BaseDataSourceOptions, SqlSe
186
186
  readonly readOnlyIntent?: boolean;
187
187
  /**
188
188
  * A boolean determining whether or not the connection will be encrypted. Set to true if you're on
189
- * Windows Azure. (default: true).
189
+ * Windows Azure. (default: false).
190
190
  */
191
191
  readonly encrypt?: boolean;
192
192
  /**
@@ -214,11 +214,6 @@ export interface SqlServerConnectionOptions extends BaseDataSourceOptions, SqlSe
214
214
  * A boolean, that when true will abort a query when an overflow or divide-by-zero error occurs during query execution.
215
215
  */
216
216
  readonly enableArithAbort?: boolean;
217
- /**
218
- * Application name used for identifying a specific application in profiling, logging or tracing tools of SQL Server.
219
- * (default: node-mssql)
220
- */
221
- readonly appName?: string;
222
217
  };
223
218
  /**
224
219
  * Replication setup.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/sqlserver/SqlServerConnectionOptions.ts"],"names":[],"mappings":"","file":"SqlServerConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { SqlServerConnectionCredentialsOptions } from \"./SqlServerConnectionCredentialsOptions\"\n\n/**\n * Microsoft Sql Server specific connection options.\n */\nexport interface SqlServerConnectionOptions\n extends BaseDataSourceOptions,\n SqlServerConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"mssql\"\n\n /**\n * Connection timeout in ms (default: 15000).\n */\n readonly connectionTimeout?: number\n\n /**\n * Request timeout in ms (default: 15000). NOTE: msnodesqlv8 driver doesn't support timeouts < 1 second.\n */\n readonly requestTimeout?: number\n\n /**\n * Stream recordsets/rows instead of returning them all at once as an argument of callback (default: false).\n * You can also enable streaming for each request independently (request.stream = true).\n * Always set to true if you plan to work with large amount of rows.\n */\n readonly stream?: boolean\n\n /**\n * Database schema.\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to `require(\"mssql\")`\n */\n readonly driver?: any\n\n /**\n * An optional object/dictionary with the any of the properties\n */\n readonly pool?: {\n /**\n * Maximum number of resources to create at any given time. (default=1)\n */\n readonly max?: number\n\n /**\n * Minimum number of resources to keep in pool at any given time. If this is set >= max, the pool will silently\n * set the min to equal max. (default=0)\n */\n readonly min?: number\n\n /**\n * Maximum number of queued requests allowed, additional acquire calls will be callback with an err in a future\n * cycle of the event loop.\n */\n readonly maxWaitingClients?: number\n\n /**\n * Should the pool validate resources before giving them to clients. Requires that either factory.validate or\n * factory.validateAsync to be specified\n */\n readonly testOnBorrow?: boolean\n\n /**\n * Max milliseconds an acquire call will wait for a resource before timing out. (default no limit), if supplied should non-zero positive integer.\n */\n readonly acquireTimeoutMillis?: number\n\n /**\n * If true the oldest resources will be first to be allocated. If false the most recently released resources will\n * be the first to be allocated. This in effect turns the pool's behaviour from a queue into a stack. boolean,\n * (default true)\n */\n readonly fifo?: boolean\n\n /**\n * Int between 1 and x - if set, borrowers can specify their relative priority in the queue if no resources\n * are available. see example. (default 1)\n */\n readonly priorityRange?: number\n\n /**\n * How often to run eviction checks. Default: 0 (does not run).\n */\n readonly evictionRunIntervalMillis?: number\n\n /**\n * Number of resources to check each eviction run. Default: 3.\n */\n readonly numTestsPerRun?: number\n\n /**\n * Amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object\n * evictor (if any), with the extra condition that at least \"min idle\" object instances remain in the pool.\n * Default -1 (nothing can get evicted)\n */\n readonly softIdleTimeoutMillis?: number\n\n /**\n * The minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due\n * to idle time. Supercedes softIdleTimeoutMillis Default: 30000\n */\n readonly idleTimeoutMillis?: number\n\n /*\n * Function handling errors thrown by drivers pool.\n * Defaults to logging error with `warn` level.\n */\n readonly errorHandler?: (err: any) => any\n }\n\n /**\n * Extra options\n */\n readonly options?: {\n /**\n * By default, if the database requestion by options.database cannot be accessed, the connection will fail with\n * an error. However, if options.fallbackToDefaultDb is set to true, then the user's default database will\n * be used instead (Default: false).\n */\n readonly fallbackToDefaultDb?: boolean\n\n /**\n * If true, SET ANSI_NULL_DFLT_ON ON will be set in the initial sql. This means new columns will be nullable by\n * default. See the T-SQL documentation for more details. (Default: true).\n */\n readonly enableAnsiNullDefault?: boolean\n\n /**\n * The number of milliseconds before the attempt to connect is considered failed (default: 15000).\n */\n readonly connectTimeout?: number\n\n /**\n * The number of milliseconds before the cancel (abort) of a request is considered failed (default: 5000).\n */\n readonly cancelTimeout?: number\n\n /**\n * The size of TDS packets (subject to negotiation with the server). Should be a power of 2. (default: 4096).\n */\n readonly packetSize?: number\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: false).\n */\n readonly useUTC?: boolean\n\n /**\n * A boolean determining whether to rollback a transaction automatically if any error is encountered during\n * the given transaction's execution. This sets the value for SET XACT_ABORT during the initial SQL phase\n * of a connection (documentation).\n */\n readonly abortTransactionOnError?: boolean\n\n /**\n * A string indicating which network interface (ip address) to use when connecting to SQL Server.\n */\n readonly localAddress?: string\n\n /**\n * A boolean determining whether to return rows as arrays or key-value collections. (default: false).\n */\n readonly useColumnNames?: boolean\n\n /**\n * A boolean, controlling whether the column names returned will have the first letter converted to lower case\n * (true) or not. This value is ignored if you provide a columnNameReplacer. (default: false).\n */\n readonly camelCaseColumns?: boolean\n\n /**\n * A boolean, controlling whatever to disable RETURNING / OUTPUT statements.\n */\n readonly disableOutputReturning?: boolean\n\n /**\n * Debug options\n */\n readonly debug?: {\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet details\n * (default: false).\n */\n readonly packet?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet data details\n * (default: false).\n */\n readonly data?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet payload details\n * (default: false).\n */\n readonly payload?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing token stream tokens\n * (default: false).\n */\n readonly token?: boolean\n }\n\n /**\n * The default isolation level that transactions will be run with. The isolation levels are available\n * from require('tedious').ISOLATION_LEVEL. (default: READ_COMMITTED).\n */\n readonly isolation?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * The default isolation level for new connections. All out-of-transaction queries are executed with this\n * setting. The isolation levels are available from require('tedious').ISOLATION_LEVEL .\n */\n readonly connectionIsolationLevel?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * A boolean, determining whether the connection will request read only access from a SQL Server\n * Availability Group. For more information, see here. (default: false).\n */\n readonly readOnlyIntent?: boolean\n\n /**\n * A boolean determining whether or not the connection will be encrypted. Set to true if you're on\n * Windows Azure. (default: true).\n */\n readonly encrypt?: boolean\n\n /**\n * When encryption is used, an object may be supplied that will be used for the first argument when calling\n * tls.createSecurePair (default: {}).\n */\n readonly cryptoCredentialsDetails?: any\n\n /**\n * A boolean, that when true will expose received rows in Requests' done* events. See done, doneInProc and\n * doneProc. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnDone?: boolean\n\n /**\n * A boolean, that when true will expose received rows in Requests' completion callback. See new Request. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnRequestCompletion?: boolean\n\n /**\n * The version of TDS to use. If server doesn't support specified version, negotiated version is used instead.\n * The versions are available from require('tedious').TDS_VERSION. (default: 7_4).\n */\n readonly tdsVersion?: string\n\n /**\n * A boolean, that when true will abort a query when an overflow or divide-by-zero error occurs during query execution.\n */\n readonly enableArithAbort?: boolean\n\n /**\n * Application name used for identifying a specific application in profiling, logging or tracing tools of SQL Server.\n * (default: node-mssql)\n */\n readonly appName?: string\n }\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: SqlServerConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: SqlServerConnectionCredentialsOptions[]\n }\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/driver/sqlserver/SqlServerConnectionOptions.ts"],"names":[],"mappings":"","file":"SqlServerConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { SqlServerConnectionCredentialsOptions } from \"./SqlServerConnectionCredentialsOptions\"\n\n/**\n * Microsoft Sql Server specific connection options.\n */\nexport interface SqlServerConnectionOptions\n extends BaseDataSourceOptions,\n SqlServerConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"mssql\"\n\n /**\n * Connection timeout in ms (default: 15000).\n */\n readonly connectionTimeout?: number\n\n /**\n * Request timeout in ms (default: 15000). NOTE: msnodesqlv8 driver doesn't support timeouts < 1 second.\n */\n readonly requestTimeout?: number\n\n /**\n * Stream recordsets/rows instead of returning them all at once as an argument of callback (default: false).\n * You can also enable streaming for each request independently (request.stream = true).\n * Always set to true if you plan to work with large amount of rows.\n */\n readonly stream?: boolean\n\n /**\n * Database schema.\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to `require(\"mssql\")`\n */\n readonly driver?: any\n\n /**\n * An optional object/dictionary with the any of the properties\n */\n readonly pool?: {\n /**\n * Maximum number of resources to create at any given time. (default=1)\n */\n readonly max?: number\n\n /**\n * Minimum number of resources to keep in pool at any given time. If this is set >= max, the pool will silently\n * set the min to equal max. (default=0)\n */\n readonly min?: number\n\n /**\n * Maximum number of queued requests allowed, additional acquire calls will be callback with an err in a future\n * cycle of the event loop.\n */\n readonly maxWaitingClients?: number\n\n /**\n * Should the pool validate resources before giving them to clients. Requires that either factory.validate or\n * factory.validateAsync to be specified\n */\n readonly testOnBorrow?: boolean\n\n /**\n * Max milliseconds an acquire call will wait for a resource before timing out. (default no limit), if supplied should non-zero positive integer.\n */\n readonly acquireTimeoutMillis?: number\n\n /**\n * If true the oldest resources will be first to be allocated. If false the most recently released resources will\n * be the first to be allocated. This in effect turns the pool's behaviour from a queue into a stack. boolean,\n * (default true)\n */\n readonly fifo?: boolean\n\n /**\n * Int between 1 and x - if set, borrowers can specify their relative priority in the queue if no resources\n * are available. see example. (default 1)\n */\n readonly priorityRange?: number\n\n /**\n * How often to run eviction checks. Default: 0 (does not run).\n */\n readonly evictionRunIntervalMillis?: number\n\n /**\n * Number of resources to check each eviction run. Default: 3.\n */\n readonly numTestsPerRun?: number\n\n /**\n * Amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object\n * evictor (if any), with the extra condition that at least \"min idle\" object instances remain in the pool.\n * Default -1 (nothing can get evicted)\n */\n readonly softIdleTimeoutMillis?: number\n\n /**\n * The minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due\n * to idle time. Supercedes softIdleTimeoutMillis Default: 30000\n */\n readonly idleTimeoutMillis?: number\n\n /*\n * Function handling errors thrown by drivers pool.\n * Defaults to logging error with `warn` level.\n */\n readonly errorHandler?: (err: any) => any\n }\n\n /**\n * Extra options\n */\n readonly options?: {\n /**\n * By default, if the database requestion by options.database cannot be accessed, the connection will fail with\n * an error. However, if options.fallbackToDefaultDb is set to true, then the user's default database will\n * be used instead (Default: false).\n */\n readonly fallbackToDefaultDb?: boolean\n\n /**\n * If true, SET ANSI_NULL_DFLT_ON ON will be set in the initial sql. This means new columns will be nullable by\n * default. See the T-SQL documentation for more details. (Default: true).\n */\n readonly enableAnsiNullDefault?: boolean\n\n /**\n * The number of milliseconds before the attempt to connect is considered failed (default: 15000).\n */\n readonly connectTimeout?: number\n\n /**\n * The number of milliseconds before the cancel (abort) of a request is considered failed (default: 5000).\n */\n readonly cancelTimeout?: number\n\n /**\n * The size of TDS packets (subject to negotiation with the server). Should be a power of 2. (default: 4096).\n */\n readonly packetSize?: number\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: false).\n */\n readonly useUTC?: boolean\n\n /**\n * A boolean determining whether to rollback a transaction automatically if any error is encountered during\n * the given transaction's execution. This sets the value for SET XACT_ABORT during the initial SQL phase\n * of a connection (documentation).\n */\n readonly abortTransactionOnError?: boolean\n\n /**\n * A string indicating which network interface (ip address) to use when connecting to SQL Server.\n */\n readonly localAddress?: string\n\n /**\n * A boolean determining whether to return rows as arrays or key-value collections. (default: false).\n */\n readonly useColumnNames?: boolean\n\n /**\n * A boolean, controlling whether the column names returned will have the first letter converted to lower case\n * (true) or not. This value is ignored if you provide a columnNameReplacer. (default: false).\n */\n readonly camelCaseColumns?: boolean\n\n /**\n * A boolean, controlling whatever to disable RETURNING / OUTPUT statements.\n */\n readonly disableOutputReturning?: boolean\n\n /**\n * Debug options\n */\n readonly debug?: {\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet details\n * (default: false).\n */\n readonly packet?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet data details\n * (default: false).\n */\n readonly data?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet payload details\n * (default: false).\n */\n readonly payload?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing token stream tokens\n * (default: false).\n */\n readonly token?: boolean\n }\n\n /**\n * The default isolation level that transactions will be run with. The isolation levels are available\n * from require('tedious').ISOLATION_LEVEL. (default: READ_COMMITTED).\n */\n readonly isolation?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * The default isolation level for new connections. All out-of-transaction queries are executed with this\n * setting. The isolation levels are available from require('tedious').ISOLATION_LEVEL .\n */\n readonly connectionIsolationLevel?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * A boolean, determining whether the connection will request read only access from a SQL Server\n * Availability Group. For more information, see here. (default: false).\n */\n readonly readOnlyIntent?: boolean\n\n /**\n * A boolean determining whether or not the connection will be encrypted. Set to true if you're on\n * Windows Azure. (default: false).\n */\n readonly encrypt?: boolean\n\n /**\n * When encryption is used, an object may be supplied that will be used for the first argument when calling\n * tls.createSecurePair (default: {}).\n */\n readonly cryptoCredentialsDetails?: any\n\n /**\n * A boolean, that when true will expose received rows in Requests' done* events. See done, doneInProc and\n * doneProc. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnDone?: boolean\n\n /**\n * A boolean, that when true will expose received rows in Requests' completion callback. See new Request. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnRequestCompletion?: boolean\n\n /**\n * The version of TDS to use. If server doesn't support specified version, negotiated version is used instead.\n * The versions are available from require('tedious').TDS_VERSION. (default: 7_4).\n */\n readonly tdsVersion?: string\n\n /**\n * A boolean, that when true will abort a query when an overflow or divide-by-zero error occurs during query execution.\n */\n readonly enableArithAbort?: boolean\n }\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: SqlServerConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: SqlServerConnectionCredentialsOptions[]\n }\n}\n"],"sourceRoot":"../.."}
@@ -195,7 +195,6 @@ class EntityManager {
195
195
  // normalize mixed parameters
196
196
  const target = arguments.length > 1 &&
197
197
  (typeof targetOrEntity === "function" ||
198
- InstanceChecker_1.InstanceChecker.isEntitySchema(targetOrEntity) ||
199
198
  typeof targetOrEntity === "string")
200
199
  ? targetOrEntity
201
200
  : undefined;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/entity-manager/EntityManager.ts"],"names":[],"mappings":";;;AAIA,sEAAkE;AAClE,8GAA0G;AAK1G,kGAA8F;AAC9F,mEAA+D;AAC/D,iEAA6D;AAC7D,yDAAqD;AACrD,uEAAmE;AACnE,sHAAkH;AAClH,gIAA4H;AAC5H,oCAKiB;AACjB,yEAAqE;AAIrE,gFAA4E;AAO5E,qDAAiD;AACjD,wCAAmD;AAEnD,6DAAyD;AAGzD;;;GAGG;AACH,MAAa,aAAa;IAsCtB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,UAAsB,EAAE,WAAyB;QAzCpD,mBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAiBpD,4EAA4E;QAC5E,uBAAuB;QACvB,4EAA4E;QAE5E;;WAEG;QACO,iBAAY,GAAsB,EAAE,CAAA;QAE9C;;WAEG;QACO,qBAAgB,GAA0B,EAAE,CAAA;QAEtD;;WAEG;QACO,mCAA8B,GACpC,IAAI,qEAAiC,EAAE,CAAA;QAOvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,WAAW,EAAE;YACb,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;YAC9B,uCAAuC;YACvC,yBAAW,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;SAC1D;IACL,CAAC;IAuBD;;;OAGG;IACH,KAAK,CAAC,WAAW,CACb,2BAEoD,EACpD,qBAAoE;QAEpE,MAAM,SAAS,GACX,OAAO,2BAA2B,KAAK,QAAQ;YAC3C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,IAAI,CAAC,CAAC,UAAU,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,qCAA6B,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,uCAAkB,EAAE;YACxD,IAAI,CAAE,wBAAgC,CAAC,SAAS,CAAC;gBAC5C,wBAAgC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAA;SAC1D;aAAM;YACH,IAAI,CAAC,cAAc;gBACf,MAAM,IAAI,oDAA4C,CAClD,gBAAgB,CACnB,CACJ;YAAC,wBAAgC,CAAC,SAAS,CAAC,GAAG,IAAI,CACnD;YAAC,wBAAgC,CAAC,UAAU,CAAC,GAAG,cAAc,CAAA;SAClE;QAED,OAAO,wBAAwB,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,qEAAiC,EAAE,CAAA;QAEpE,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;IACrC,CAAC;CACJ;AAr2CD,sCAq2CC","file":"EntityManager.js","sourcesContent":["import { DataSource } from \"../data-source/DataSource\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { ObjectType } from \"../common/ObjectType\"\nimport { EntityNotFoundError } from \"../error/EntityNotFoundError\"\nimport { QueryRunnerProviderAlreadyReleasedError } from \"../error/QueryRunnerProviderAlreadyReleasedError\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { RemoveOptions } from \"../repository/RemoveOptions\"\nimport { SaveOptions } from \"../repository/SaveOptions\"\nimport { NoNeedToReleaseEntityManagerError } from \"../error/NoNeedToReleaseEntityManagerError\"\nimport { MongoRepository } from \"../repository/MongoRepository\"\nimport { TreeRepository } from \"../repository/TreeRepository\"\nimport { Repository } from \"../repository/Repository\"\nimport { FindOptionsUtils } from \"../find-options/FindOptionsUtils\"\nimport { PlainObjectToNewEntityTransformer } from \"../query-builder/transformer/PlainObjectToNewEntityTransformer\"\nimport { PlainObjectToDatabaseEntityTransformer } from \"../query-builder/transformer/PlainObjectToDatabaseEntityTransformer\"\nimport {\n CustomRepositoryCannotInheritRepositoryError,\n CustomRepositoryNotFoundError,\n TreeRepositoryNotSupportedError,\n TypeORMError,\n} from \"../error\"\nimport { AbstractRepository } from \"../repository/AbstractRepository\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { EntityPersistExecutor } from \"../persistence/EntityPersistExecutor\"\nimport { ObjectID } from \"../driver/mongodb/typings\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { IsolationLevel } from \"../driver/types/IsolationLevel\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { getMetadataArgsStorage } from \"../globals\"\nimport { UpsertOptions } from \"../repository/UpsertOptions\"\nimport { InstanceChecker } from \"../util/InstanceChecker\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\n\n/**\n * Entity manager supposed to work with any entity, automatically find its repository and call its methods,\n * whatever entity type are you passing.\n */\nexport class EntityManager {\n readonly \"@instanceof\" = Symbol.for(\"EntityManager\")\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by this entity manager.\n */\n readonly connection: DataSource\n\n /**\n * Custom query runner to be used for operations in this entity manager.\n * Used only in non-global entity manager.\n */\n readonly queryRunner?: QueryRunner\n\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Once created and then reused by repositories.\n */\n protected repositories: Repository<any>[] = []\n\n /**\n * Once created and then reused by repositories.\n */\n protected treeRepositories: TreeRepository<any>[] = []\n\n /**\n * Plain to object transformer used in create and merge operations.\n */\n protected plainObjectToEntityTransformer =\n new PlainObjectToNewEntityTransformer()\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource, queryRunner?: QueryRunner) {\n this.connection = connection\n if (queryRunner) {\n this.queryRunner = queryRunner\n // dynamic: this.queryRunner = manager;\n ObjectUtils.assign(this.queryRunner, { manager: this })\n }\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n isolationLevel: IsolationLevel,\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n isolationOrRunInTransaction:\n | IsolationLevel\n | ((entityManager: EntityManager) => Promise<T>),\n runInTransactionParam?: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T> {\n const isolation =\n typeof isolationOrRunInTransaction === \"string\"\n ? isolationOrRunInTransaction\n : undefined\n const runInTransaction =\n typeof isolationOrRunInTransaction === \"function\"\n ? isolationOrRunInTransaction\n : runInTransactionParam\n\n if (!runInTransaction) {\n throw new TypeORMError(\n `Transaction method requires callback in second parameter if isolation level is supplied.`,\n )\n }\n\n if (this.queryRunner && this.queryRunner.isReleased)\n throw new QueryRunnerProviderAlreadyReleasedError()\n\n // if query runner is already defined in this class, it means this entity manager was already created for a single connection\n // if its not defined we create a new query runner - single connection where we'll execute all our operations\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n try {\n await queryRunner.startTransaction(isolation)\n const result = await runInTransaction(queryRunner.manager)\n await queryRunner.commitTransaction()\n return result\n } catch (err) {\n try {\n // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n throw err\n } finally {\n if (!this.queryRunner)\n // if we used a new query runner provider then release it\n await queryRunner.release()\n }\n }\n\n /**\n * Executes raw SQL query and returns raw database results.\n */\n async query(query: string, parameters?: any[]): Promise<any> {\n return this.connection.query(query, parameters, this.queryRunner)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass: EntityTarget<Entity>,\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass?: EntityTarget<Entity> | QueryRunner,\n alias?: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n if (alias) {\n return this.connection.createQueryBuilder(\n entityClass as EntityTarget<Entity>,\n alias,\n queryRunner || this.queryRunner,\n )\n } else {\n return this.connection.createQueryBuilder(\n (entityClass as QueryRunner | undefined) ||\n queryRunner ||\n this.queryRunner,\n )\n }\n }\n\n /**\n * Checks if entity has an id.\n */\n hasId(entity: any): boolean\n\n /**\n * Checks if entity of given schema name has an id.\n */\n hasId(target: Function | string, entity: any): boolean\n\n /**\n * Checks if entity has an id by its Function type or schema name.\n */\n hasId(targetOrEntity: any | Function | string, maybeEntity?: any): boolean {\n const target =\n arguments.length === 2 ? targetOrEntity : targetOrEntity.constructor\n const entity = arguments.length === 2 ? maybeEntity : targetOrEntity\n const metadata = this.connection.getMetadata(target)\n return metadata.hasId(entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: any): any\n\n /**\n * Gets entity mixed id.\n */\n getId(target: EntityTarget<any>, entity: any): any\n\n /**\n * Gets entity mixed id.\n */\n getId(targetOrEntity: any | EntityTarget<any>, maybeEntity?: any): any {\n const target =\n arguments.length === 2 ? targetOrEntity : targetOrEntity.constructor\n const entity = arguments.length === 2 ? maybeEntity : targetOrEntity\n const metadata = this.connection.getMetadata(target)\n return metadata.getEntityIdMixedMap(entity)\n }\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObject?: DeepPartial<Entity>,\n ): Entity\n\n /**\n * Creates a new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that present in entity schema.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObjects?: DeepPartial<Entity>[],\n ): Entity[]\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObjectOrObjects?: DeepPartial<Entity> | DeepPartial<Entity>[],\n ): Entity | Entity[] {\n const metadata = this.connection.getMetadata(entityClass)\n\n if (!plainObjectOrObjects) return metadata.create(this.queryRunner)\n\n if (Array.isArray(plainObjectOrObjects))\n return (plainObjectOrObjects as DeepPartial<Entity>[]).map(\n (plainEntityLike) => this.create(entityClass, plainEntityLike),\n )\n\n const mergeIntoEntity = metadata.create(this.queryRunner)\n this.plainObjectToEntityTransformer.transform(\n mergeIntoEntity,\n plainObjectOrObjects,\n metadata,\n true,\n )\n return mergeIntoEntity\n }\n\n /**\n * Merges two entities into one new entity.\n */\n merge<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n mergeIntoEntity: Entity,\n ...entityLikes: DeepPartial<Entity>[]\n ): Entity {\n // todo: throw exception if entity manager is released\n const metadata = this.connection.getMetadata(entityClass)\n entityLikes.forEach((object) =>\n this.plainObjectToEntityTransformer.transform(\n mergeIntoEntity,\n object,\n metadata,\n ),\n )\n return mergeIntoEntity\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n */\n async preload<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n entityLike: DeepPartial<Entity>,\n ): Promise<Entity | undefined> {\n const metadata = this.connection.getMetadata(entityClass)\n const plainObjectToDatabaseEntityTransformer =\n new PlainObjectToDatabaseEntityTransformer(this.connection.manager)\n const transformedEntity =\n await plainObjectToDatabaseEntityTransformer.transform(\n entityLike,\n metadata,\n )\n if (transformedEntity)\n return this.merge(\n entityClass as any,\n transformedEntity as Entity,\n entityLike,\n )\n\n return undefined\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity>(entities: Entity[], options?: SaveOptions): Promise<Entity[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Saves a given entity in the database.\n */\n save<Entity extends ObjectLiteral, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute save operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"save\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(entity: Entity, options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n entity: Entity,\n options?: RemoveOptions,\n ): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(entity: Entity[], options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n entity: Entity[],\n options?: RemoveOptions,\n ): Promise<Entity[]>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity extends ObjectLiteral>(\n targetOrEntity: (Entity | Entity[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: Entity | Entity[],\n maybeOptions?: RemoveOptions,\n ): Promise<Entity | Entity[]> {\n // normalize mixed parameters\n const target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n 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>(\n target: EntityTarget<Entity>,\n entity:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n ): Promise<InsertResult> {\n return this.createQueryBuilder()\n .insert()\n .into(target)\n .values(entity)\n .execute()\n }\n\n async upsert<Entity>(\n target: EntityTarget<Entity>,\n entityOrEntities:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>,\n ): Promise<InsertResult> {\n const metadata = this.connection.getMetadata(target)\n\n let options: UpsertOptions<Entity>\n\n if (Array.isArray(conflictPathsOrOptions)) {\n options = {\n conflictPaths: conflictPathsOrOptions,\n }\n } else {\n options = conflictPathsOrOptions\n }\n\n let entities: QueryDeepPartialEntity<Entity>[]\n\n if (!Array.isArray(entityOrEntities)) {\n entities = [entityOrEntities]\n } else {\n entities = entityOrEntities\n }\n\n const conflictColumns = metadata.mapPropertyPathsToColumns(\n options.conflictPaths,\n )\n\n const overwriteColumns = metadata.columns.filter(\n (col) =>\n !conflictColumns.includes(col) &&\n entities.some(\n (entity) =>\n typeof col.getEntityValue(entity) !== \"undefined\",\n ),\n )\n\n return this.createQueryBuilder()\n .insert()\n .into(target)\n .values(entities)\n .orUpdate(\n [...conflictColumns, ...overwriteColumns].map(\n (col) => col.databaseName,\n ),\n conflictColumns.map((col) => col.databaseName),\n {\n skipUpdateIfNoValuesChanged:\n options.skipUpdateIfNoValuesChanged,\n },\n )\n .execute()\n }\n\n /**\n * Updates entity partially. Entity can be found by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n update<Entity>(\n target: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n partialEntity: QueryDeepPartialEntity<Entity>,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the update method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Deletes entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n delete<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<DeleteResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .delete()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .delete()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Records the delete date of entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n softDelete<Entity extends ObjectLiteral>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .softDelete()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .softDelete()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Restores entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n restore<Entity extends ObjectLiteral>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .restore()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .restore()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Counts entities that match given options.\n * Useful for pagination.\n */\n count<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<number> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(\n entityClass,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getCount()\n }\n\n /**\n * Counts entities that match given conditions.\n * Useful for pagination.\n */\n countBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(entityClass, metadata.name)\n .setFindOptions({ where })\n .getCount()\n }\n\n /**\n * Finds entities that match given find options.\n */\n async find<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<Entity[]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getMany()\n }\n\n /**\n * Finds entities that match given find options.\n */\n async findBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity[]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .setFindOptions({ where: where })\n .getMany()\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getManyAndCount()\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<[Entity[], number]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .setFindOptions({ where })\n .getManyAndCount()\n }\n\n /**\n * Finds entities with ids.\n * Optionally find options or conditions can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n async findByIds<Entity>(\n entityClass: EntityTarget<Entity>,\n ids: any[],\n ): Promise<Entity[]> {\n // if no ids passed, no need to execute a query - just return an empty array of values\n if (!ids.length) return Promise.resolve([])\n\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .andWhereInIds(ids)\n .getMany()\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - returns null.\n */\n async findOne<Entity>(\n entityClass: EntityTarget<Entity>,\n options: FindOneOptions<Entity>,\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // prepare alias for built query\n let alias: string = metadata.name\n if (options && options.join) {\n alias = options.join.alias\n }\n\n if (!options.where) {\n throw new Error(\n `You must provide selection conditions in order to find a single row.`,\n )\n }\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, alias)\n .setFindOptions({\n ...options,\n take: 1,\n })\n .getOne()\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - returns null.\n */\n async findOneBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, metadata.name)\n .setFindOptions({\n where,\n take: 1,\n })\n .getOne()\n }\n\n /**\n * Finds first entity that matches given id.\n * If entity was not found in the database - returns null.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById<Entity>(\n entityClass: EntityTarget<Entity>,\n id: number | string | Date | ObjectID,\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, metadata.name)\n .setFindOptions({\n take: 1,\n })\n .whereInIds(metadata.ensureEntityIdMap(id))\n .getOne()\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail<Entity>(\n entityClass: EntityTarget<Entity>,\n options: FindOneOptions<Entity>,\n ): Promise<Entity> {\n return this.findOne<Entity>(entityClass as any, options).then(\n (value) => {\n if (value === null) {\n return Promise.reject(\n new EntityNotFoundError(entityClass, options),\n )\n }\n return Promise.resolve(value)\n },\n )\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity> {\n return this.findOneBy<Entity>(entityClass as any, where).then(\n (value) => {\n if (value === null) {\n return Promise.reject(\n new EntityNotFoundError(entityClass, where),\n )\n }\n return Promise.resolve(value)\n },\n )\n }\n\n /**\n * Clears all the data from the given table (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n async clear<Entity>(entityClass: EntityTarget<Entity>): Promise<void> {\n const metadata = this.connection.getMetadata(entityClass)\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n try {\n return await queryRunner.clearTable(metadata.tablePath) // await is needed here because we are using finally\n } finally {\n if (!this.queryRunner) await queryRunner.release()\n }\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n async increment<Entity>(\n entityClass: EntityTarget<Entity>,\n conditions: any,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.findColumnWithPropertyPath(propertyPath)\n if (!column)\n throw new TypeORMError(\n `Column ${propertyPath} was not found in ${metadata.targetName} entity.`,\n )\n\n if (isNaN(Number(value)))\n throw new TypeORMError(`Value \"${value}\" is not a number.`)\n\n // convert possible embeded path \"social.likes\" into object { social: { like: () => value } }\n const values: QueryDeepPartialEntity<Entity> = propertyPath\n .split(\".\")\n .reduceRight(\n (value, key) => ({ [key]: value } as any),\n () =>\n this.connection.driver.escape(column.databaseName) +\n \" + \" +\n value,\n )\n\n return this.createQueryBuilder<Entity>(entityClass as any, \"entity\")\n .update(entityClass)\n .set(values)\n .where(conditions)\n .execute()\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n async decrement<Entity>(\n entityClass: EntityTarget<Entity>,\n conditions: any,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.findColumnWithPropertyPath(propertyPath)\n if (!column)\n throw new TypeORMError(\n `Column ${propertyPath} was not found in ${metadata.targetName} entity.`,\n )\n\n if (isNaN(Number(value)))\n throw new TypeORMError(`Value \"${value}\" is not a number.`)\n\n // convert possible embeded path \"social.likes\" into object { social: { like: () => value } }\n const values: QueryDeepPartialEntity<Entity> = propertyPath\n .split(\".\")\n .reduceRight(\n (value, key) => ({ [key]: value } as any),\n () =>\n this.connection.driver.escape(column.databaseName) +\n \" - \" +\n value,\n )\n\n return this.createQueryBuilder<Entity>(entityClass as any, \"entity\")\n .update(entityClass)\n .set(values)\n .where(conditions)\n .execute()\n }\n\n /**\n * Gets repository for the given entity class or name.\n * If single database connection mode is used, then repository is obtained from the\n * repository aggregator, where each repository is individually created for this entity manager.\n * When single database connection is not used, repository is being obtained from the connection.\n */\n getRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): Repository<Entity> {\n // find already created repository instance and return it if found\n const repository = this.repositories.find(\n (repository) => repository.target === target,\n )\n if (repository) return repository\n\n // if repository was not found then create it, store its instance and return it\n if (this.connection.driver.options.type === \"mongodb\") {\n const newRepository = new MongoRepository(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.push(newRepository as any)\n return newRepository\n } else {\n const newRepository = new Repository<any>(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.push(newRepository)\n return newRepository\n }\n }\n\n /**\n * Gets tree repository for the given entity class or name.\n * If single database connection mode is used, then repository is obtained from the\n * repository aggregator, where each repository is individually created for this entity manager.\n * When single database connection is not used, repository is being obtained from the connection.\n */\n getTreeRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): TreeRepository<Entity> {\n // tree tables aren't supported by some drivers (mongodb)\n if (this.connection.driver.treeSupport === false)\n throw new TreeRepositoryNotSupportedError(this.connection.driver)\n\n // find already created repository instance and return it if found\n const repository = this.treeRepositories.find(\n (repository) => repository.target === target,\n )\n if (repository) return repository\n\n // check if repository is real tree repository\n const newRepository = new TreeRepository(target, this, this.queryRunner)\n this.treeRepositories.push(newRepository)\n return newRepository\n }\n\n /**\n * Gets mongodb repository for the given entity class.\n */\n getMongoRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): MongoRepository<Entity> {\n return this.connection.getMongoRepository<Entity>(target)\n }\n\n /**\n * Creates a new repository instance out of a given Repository and\n * sets current EntityManager instance to it. Used to work with custom repositories\n * in transactions.\n */\n withRepository<Entity extends ObjectLiteral, R extends Repository<Entity>>(\n repository: R,\n ): R {\n const repositoryConstructor =\n repository.constructor as typeof Repository\n const { target, manager, queryRunner, ...otherRepositoryProperties } =\n repository\n return Object.assign(\n new repositoryConstructor(repository.target, this) as R,\n {\n ...otherRepositoryProperties,\n },\n )\n }\n\n /**\n * Gets custom entity repository marked with @EntityRepository decorator.\n *\n * @deprecated use Repository.extend to create custom repositories\n */\n getCustomRepository<T>(customRepository: ObjectType<T>): T {\n const entityRepositoryMetadataArgs =\n getMetadataArgsStorage().entityRepositories.find((repository) => {\n return (\n repository.target ===\n (typeof customRepository === \"function\"\n ? customRepository\n : (customRepository as any).constructor)\n )\n })\n if (!entityRepositoryMetadataArgs)\n throw new CustomRepositoryNotFoundError(customRepository)\n\n const entityMetadata = entityRepositoryMetadataArgs.entity\n ? this.connection.getMetadata(entityRepositoryMetadataArgs.entity)\n : undefined\n const entityRepositoryInstance =\n new (entityRepositoryMetadataArgs.target as any)(\n this,\n entityMetadata,\n )\n\n // NOTE: dynamic access to protected properties. We need this to prevent unwanted properties in those classes to be exposed,\n // however we need these properties for internal work of the class\n if (entityRepositoryInstance instanceof AbstractRepository) {\n if (!(entityRepositoryInstance as any)[\"manager\"])\n (entityRepositoryInstance as any)[\"manager\"] = this\n } else {\n if (!entityMetadata)\n throw new CustomRepositoryCannotInheritRepositoryError(\n customRepository,\n )\n ;(entityRepositoryInstance as any)[\"manager\"] = this\n ;(entityRepositoryInstance as any)[\"metadata\"] = entityMetadata\n }\n\n return entityRepositoryInstance\n }\n\n /**\n * Releases all resources used by entity manager.\n * This is used when entity manager is created with a single query runner,\n * and this single query runner needs to be released after job with entity manager is done.\n */\n async release(): Promise<void> {\n if (!this.queryRunner) throw new NoNeedToReleaseEntityManagerError()\n\n return this.queryRunner.release()\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/entity-manager/EntityManager.ts"],"names":[],"mappings":";;;AAIA,sEAAkE;AAClE,8GAA0G;AAK1G,kGAA8F;AAC9F,mEAA+D;AAC/D,iEAA6D;AAC7D,yDAAqD;AACrD,uEAAmE;AACnE,sHAAkH;AAClH,gIAA4H;AAC5H,oCAKiB;AACjB,yEAAqE;AAIrE,gFAA4E;AAO5E,qDAAiD;AACjD,wCAAmD;AAEnD,6DAAyD;AAGzD;;;GAGG;AACH,MAAa,aAAa;IAsCtB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,UAAsB,EAAE,WAAyB;QAzCpD,mBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAiBpD,4EAA4E;QAC5E,uBAAuB;QACvB,4EAA4E;QAE5E;;WAEG;QACO,iBAAY,GAAsB,EAAE,CAAA;QAE9C;;WAEG;QACO,qBAAgB,GAA0B,EAAE,CAAA;QAEtD;;WAEG;QACO,mCAA8B,GACpC,IAAI,qEAAiC,EAAE,CAAA;QAOvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,WAAW,EAAE;YACb,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;YAC9B,uCAAuC;YACvC,yBAAW,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;SAC1D;IACL,CAAC;IAuBD;;;OAGG;IACH,KAAK,CAAC,WAAW,CACb,2BAEoD,EACpD,qBAAoE;QAEpE,MAAM,SAAS,GACX,OAAO,2BAA2B,KAAK,QAAQ;YA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D,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,qCAA6B,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,uCAAkB,EAAE;YACxD,IAAI,CAAE,wBAAgC,CAAC,SAAS,CAAC;gBAC5C,wBAAgC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAA;SAC1D;aAAM;YACH,IAAI,CAAC,cAAc;gBACf,MAAM,IAAI,oDAA4C,CAClD,gBAAgB,CACnB,CACJ;YAAC,wBAAgC,CAAC,SAAS,CAAC,GAAG,IAAI,CACnD;YAAC,wBAAgC,CAAC,UAAU,CAAC,GAAG,cAAc,CAAA;SAClE;QAED,OAAO,wBAAwB,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,qEAAiC,EAAE,CAAA;QAEpE,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;IACrC,CAAC;CACJ;AAp2CD,sCAo2CC","file":"EntityManager.js","sourcesContent":["import { DataSource } from \"../data-source/DataSource\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { ObjectType } from \"../common/ObjectType\"\nimport { EntityNotFoundError } from \"../error/EntityNotFoundError\"\nimport { QueryRunnerProviderAlreadyReleasedError } from \"../error/QueryRunnerProviderAlreadyReleasedError\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { RemoveOptions } from \"../repository/RemoveOptions\"\nimport { SaveOptions } from \"../repository/SaveOptions\"\nimport { NoNeedToReleaseEntityManagerError } from \"../error/NoNeedToReleaseEntityManagerError\"\nimport { MongoRepository } from \"../repository/MongoRepository\"\nimport { TreeRepository } from \"../repository/TreeRepository\"\nimport { Repository } from \"../repository/Repository\"\nimport { FindOptionsUtils } from \"../find-options/FindOptionsUtils\"\nimport { PlainObjectToNewEntityTransformer } from \"../query-builder/transformer/PlainObjectToNewEntityTransformer\"\nimport { PlainObjectToDatabaseEntityTransformer } from \"../query-builder/transformer/PlainObjectToDatabaseEntityTransformer\"\nimport {\n CustomRepositoryCannotInheritRepositoryError,\n CustomRepositoryNotFoundError,\n TreeRepositoryNotSupportedError,\n TypeORMError,\n} from \"../error\"\nimport { AbstractRepository } from \"../repository/AbstractRepository\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { EntityPersistExecutor } from \"../persistence/EntityPersistExecutor\"\nimport { ObjectID } from \"../driver/mongodb/typings\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { IsolationLevel } from \"../driver/types/IsolationLevel\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { getMetadataArgsStorage } from \"../globals\"\nimport { UpsertOptions } from \"../repository/UpsertOptions\"\nimport { InstanceChecker } from \"../util/InstanceChecker\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\n\n/**\n * Entity manager supposed to work with any entity, automatically find its repository and call its methods,\n * whatever entity type are you passing.\n */\nexport class EntityManager {\n readonly \"@instanceof\" = Symbol.for(\"EntityManager\")\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by this entity manager.\n */\n readonly connection: DataSource\n\n /**\n * Custom query runner to be used for operations in this entity manager.\n * Used only in non-global entity manager.\n */\n readonly queryRunner?: QueryRunner\n\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Once created and then reused by repositories.\n */\n protected repositories: Repository<any>[] = []\n\n /**\n * Once created and then reused by repositories.\n */\n protected treeRepositories: TreeRepository<any>[] = []\n\n /**\n * Plain to object transformer used in create and merge operations.\n */\n protected plainObjectToEntityTransformer =\n new PlainObjectToNewEntityTransformer()\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource, queryRunner?: QueryRunner) {\n this.connection = connection\n if (queryRunner) {\n this.queryRunner = queryRunner\n // dynamic: this.queryRunner = manager;\n ObjectUtils.assign(this.queryRunner, { manager: this })\n }\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n isolationLevel: IsolationLevel,\n runInTransaction: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T>\n\n /**\n * Wraps given function execution (and all operations made there) in a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(\n isolationOrRunInTransaction:\n | IsolationLevel\n | ((entityManager: EntityManager) => Promise<T>),\n runInTransactionParam?: (entityManager: EntityManager) => Promise<T>,\n ): Promise<T> {\n const isolation =\n typeof isolationOrRunInTransaction === \"string\"\n ? isolationOrRunInTransaction\n : undefined\n const runInTransaction =\n typeof isolationOrRunInTransaction === \"function\"\n ? isolationOrRunInTransaction\n : runInTransactionParam\n\n if (!runInTransaction) {\n throw new TypeORMError(\n `Transaction method requires callback in second parameter if isolation level is supplied.`,\n )\n }\n\n if (this.queryRunner && this.queryRunner.isReleased)\n throw new QueryRunnerProviderAlreadyReleasedError()\n\n // if query runner is already defined in this class, it means this entity manager was already created for a single connection\n // if its not defined we create a new query runner - single connection where we'll execute all our operations\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n try {\n await queryRunner.startTransaction(isolation)\n const result = await runInTransaction(queryRunner.manager)\n await queryRunner.commitTransaction()\n return result\n } catch (err) {\n try {\n // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n throw err\n } finally {\n if (!this.queryRunner)\n // if we used a new query runner provider then release it\n await queryRunner.release()\n }\n }\n\n /**\n * Executes raw SQL query and returns raw database results.\n */\n async query(query: string, parameters?: any[]): Promise<any> {\n return this.connection.query(query, parameters, this.queryRunner)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass: EntityTarget<Entity>,\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(\n entityClass?: EntityTarget<Entity> | QueryRunner,\n alias?: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n if (alias) {\n return this.connection.createQueryBuilder(\n entityClass as EntityTarget<Entity>,\n alias,\n queryRunner || this.queryRunner,\n )\n } else {\n return this.connection.createQueryBuilder(\n (entityClass as QueryRunner | undefined) ||\n queryRunner ||\n this.queryRunner,\n )\n }\n }\n\n /**\n * Checks if entity has an id.\n */\n hasId(entity: any): boolean\n\n /**\n * Checks if entity of given schema name has an id.\n */\n hasId(target: Function | string, entity: any): boolean\n\n /**\n * Checks if entity has an id by its Function type or schema name.\n */\n hasId(targetOrEntity: any | Function | string, maybeEntity?: any): boolean {\n const target =\n arguments.length === 2 ? targetOrEntity : targetOrEntity.constructor\n const entity = arguments.length === 2 ? maybeEntity : targetOrEntity\n const metadata = this.connection.getMetadata(target)\n return metadata.hasId(entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: any): any\n\n /**\n * Gets entity mixed id.\n */\n getId(target: EntityTarget<any>, entity: any): any\n\n /**\n * Gets entity mixed id.\n */\n getId(targetOrEntity: any | EntityTarget<any>, maybeEntity?: any): any {\n const target =\n arguments.length === 2 ? targetOrEntity : targetOrEntity.constructor\n const entity = arguments.length === 2 ? maybeEntity : targetOrEntity\n const metadata = this.connection.getMetadata(target)\n return metadata.getEntityIdMixedMap(entity)\n }\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObject?: DeepPartial<Entity>,\n ): Entity\n\n /**\n * Creates a new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that present in entity schema.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObjects?: DeepPartial<Entity>[],\n ): Entity[]\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create<Entity>(\n entityClass: EntityTarget<Entity>,\n plainObjectOrObjects?: DeepPartial<Entity> | DeepPartial<Entity>[],\n ): Entity | Entity[] {\n const metadata = this.connection.getMetadata(entityClass)\n\n if (!plainObjectOrObjects) return metadata.create(this.queryRunner)\n\n if (Array.isArray(plainObjectOrObjects))\n return (plainObjectOrObjects as DeepPartial<Entity>[]).map(\n (plainEntityLike) => this.create(entityClass, plainEntityLike),\n )\n\n const mergeIntoEntity = metadata.create(this.queryRunner)\n this.plainObjectToEntityTransformer.transform(\n mergeIntoEntity,\n plainObjectOrObjects,\n metadata,\n true,\n )\n return mergeIntoEntity\n }\n\n /**\n * Merges two entities into one new entity.\n */\n merge<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n mergeIntoEntity: Entity,\n ...entityLikes: DeepPartial<Entity>[]\n ): Entity {\n // todo: throw exception if entity manager is released\n const metadata = this.connection.getMetadata(entityClass)\n entityLikes.forEach((object) =>\n this.plainObjectToEntityTransformer.transform(\n mergeIntoEntity,\n object,\n metadata,\n ),\n )\n return mergeIntoEntity\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n */\n async preload<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n entityLike: DeepPartial<Entity>,\n ): Promise<Entity | undefined> {\n const metadata = this.connection.getMetadata(entityClass)\n const plainObjectToDatabaseEntityTransformer =\n new PlainObjectToDatabaseEntityTransformer(this.connection.manager)\n const transformedEntity =\n await plainObjectToDatabaseEntityTransformer.transform(\n entityLike,\n metadata,\n )\n if (transformedEntity)\n return this.merge(\n entityClass as any,\n transformedEntity as Entity,\n entityLike,\n )\n\n return undefined\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity>(entities: Entity[], options?: SaveOptions): Promise<Entity[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Saves a given entity in the database.\n */\n save<Entity extends ObjectLiteral, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute save operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"save\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(entity: Entity, options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n entity: Entity,\n options?: RemoveOptions,\n ): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(entity: Entity[], options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n entity: Entity[],\n options?: RemoveOptions,\n ): Promise<Entity[]>\n\n /**\n * Removes a given entity from the database.\n */\n remove<Entity extends ObjectLiteral>(\n targetOrEntity: (Entity | Entity[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: Entity | Entity[],\n maybeOptions?: RemoveOptions,\n ): Promise<Entity | Entity[]> {\n // normalize mixed parameters\n const target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: Entity | Entity[] = target\n ? (maybeEntityOrOptions as Entity | Entity[])\n : (targetOrEntity as Entity | Entity[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute save operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"remove\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<Entity>(\n entities: Entity[],\n options?: SaveOptions,\n ): Promise<Entity[]>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<Entity extends ObjectLiteral, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute soft-remove operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"soft-remove\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Recovers all given entities.\n */\n recover<Entity>(\n entities: Entity[],\n options?: SaveOptions,\n ): Promise<Entity[]>\n\n /**\n * Recovers a given entity.\n */\n recover<Entity>(entity: Entity, options?: SaveOptions): Promise<Entity>\n\n /**\n * Recovers all given entities.\n */\n recover<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Recovers a given entity.\n */\n recover<Entity, T extends DeepPartial<Entity>>(\n targetOrEntity: EntityTarget<Entity>,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Recovers one or many given entities.\n */\n recover<Entity extends ObjectLiteral, T extends DeepPartial<Entity>>(\n targetOrEntity: (T | T[]) | EntityTarget<Entity>,\n maybeEntityOrOptions?: T | T[],\n maybeOptions?: SaveOptions,\n ): Promise<T | T[]> {\n // normalize mixed parameters\n let target =\n arguments.length > 1 &&\n (typeof targetOrEntity === \"function\" ||\n InstanceChecker.isEntitySchema(targetOrEntity) ||\n typeof targetOrEntity === \"string\")\n ? (targetOrEntity as Function | string)\n : undefined\n const entity: T | T[] = target\n ? (maybeEntityOrOptions as T | T[])\n : (targetOrEntity as T | T[])\n const options = target\n ? maybeOptions\n : (maybeEntityOrOptions as SaveOptions)\n\n if (InstanceChecker.isEntitySchema(target)) target = target.options.name\n\n // if user passed empty array of entities then we don't need to do anything\n if (Array.isArray(entity) && entity.length === 0)\n return Promise.resolve(entity)\n\n // execute recover operation\n return new EntityPersistExecutor(\n this.connection,\n this.queryRunner,\n \"recover\",\n target,\n entity,\n options,\n )\n .execute()\n .then(() => entity)\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n * You can execute bulk inserts using this method.\n */\n async insert<Entity>(\n target: EntityTarget<Entity>,\n entity:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n ): Promise<InsertResult> {\n return this.createQueryBuilder()\n .insert()\n .into(target)\n .values(entity)\n .execute()\n }\n\n async upsert<Entity>(\n target: EntityTarget<Entity>,\n entityOrEntities:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>,\n ): Promise<InsertResult> {\n const metadata = this.connection.getMetadata(target)\n\n let options: UpsertOptions<Entity>\n\n if (Array.isArray(conflictPathsOrOptions)) {\n options = {\n conflictPaths: conflictPathsOrOptions,\n }\n } else {\n options = conflictPathsOrOptions\n }\n\n let entities: QueryDeepPartialEntity<Entity>[]\n\n if (!Array.isArray(entityOrEntities)) {\n entities = [entityOrEntities]\n } else {\n entities = entityOrEntities\n }\n\n const conflictColumns = metadata.mapPropertyPathsToColumns(\n options.conflictPaths,\n )\n\n const overwriteColumns = metadata.columns.filter(\n (col) =>\n !conflictColumns.includes(col) &&\n entities.some(\n (entity) =>\n typeof col.getEntityValue(entity) !== \"undefined\",\n ),\n )\n\n return this.createQueryBuilder()\n .insert()\n .into(target)\n .values(entities)\n .orUpdate(\n [...conflictColumns, ...overwriteColumns].map(\n (col) => col.databaseName,\n ),\n conflictColumns.map((col) => col.databaseName),\n {\n skipUpdateIfNoValuesChanged:\n options.skipUpdateIfNoValuesChanged,\n },\n )\n .execute()\n }\n\n /**\n * Updates entity partially. Entity can be found by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n update<Entity>(\n target: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n partialEntity: QueryDeepPartialEntity<Entity>,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the update method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .update(target)\n .set(partialEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Deletes entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n delete<Entity>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<DeleteResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .delete()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .delete()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Records the delete date of entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n softDelete<Entity extends ObjectLiteral>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .softDelete()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .softDelete()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Restores entities by a given condition(s).\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n * Condition(s) cannot be empty.\n */\n restore<Entity extends ObjectLiteral>(\n targetOrEntity: EntityTarget<Entity>,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | any,\n ): Promise<UpdateResult> {\n // if user passed empty criteria or empty list of criterias, then throw an error\n if (\n criteria === undefined ||\n criteria === null ||\n criteria === \"\" ||\n (Array.isArray(criteria) && criteria.length === 0)\n ) {\n return Promise.reject(\n new TypeORMError(\n `Empty criteria(s) are not allowed for the delete method.`,\n ),\n )\n }\n\n if (\n typeof criteria === \"string\" ||\n typeof criteria === \"number\" ||\n criteria instanceof Date ||\n Array.isArray(criteria)\n ) {\n return this.createQueryBuilder()\n .restore()\n .from(targetOrEntity)\n .whereInIds(criteria)\n .execute()\n } else {\n return this.createQueryBuilder()\n .restore()\n .from(targetOrEntity)\n .where(criteria)\n .execute()\n }\n }\n\n /**\n * Counts entities that match given options.\n * Useful for pagination.\n */\n count<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<number> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(\n entityClass,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getCount()\n }\n\n /**\n * Counts entities that match given conditions.\n * Useful for pagination.\n */\n countBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder(entityClass, metadata.name)\n .setFindOptions({ where })\n .getCount()\n }\n\n /**\n * Finds entities that match given find options.\n */\n async find<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<Entity[]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getMany()\n }\n\n /**\n * Finds entities that match given find options.\n */\n async findBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity[]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .setFindOptions({ where: where })\n .getMany()\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount<Entity>(\n entityClass: EntityTarget<Entity>,\n options?: FindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n FindOptionsUtils.extractFindManyOptionsAlias(options) ||\n metadata.name,\n )\n .setFindOptions(options || {})\n .getManyAndCount()\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<[Entity[], number]> {\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .setFindOptions({ where })\n .getManyAndCount()\n }\n\n /**\n * Finds entities with ids.\n * Optionally find options or conditions can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n async findByIds<Entity>(\n entityClass: EntityTarget<Entity>,\n ids: any[],\n ): Promise<Entity[]> {\n // if no ids passed, no need to execute a query - just return an empty array of values\n if (!ids.length) return Promise.resolve([])\n\n const metadata = this.connection.getMetadata(entityClass)\n return this.createQueryBuilder<Entity>(\n entityClass as any,\n metadata.name,\n )\n .andWhereInIds(ids)\n .getMany()\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - returns null.\n */\n async findOne<Entity>(\n entityClass: EntityTarget<Entity>,\n options: FindOneOptions<Entity>,\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // prepare alias for built query\n let alias: string = metadata.name\n if (options && options.join) {\n alias = options.join.alias\n }\n\n if (!options.where) {\n throw new Error(\n `You must provide selection conditions in order to find a single row.`,\n )\n }\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, alias)\n .setFindOptions({\n ...options,\n take: 1,\n })\n .getOne()\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - returns null.\n */\n async findOneBy<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, metadata.name)\n .setFindOptions({\n where,\n take: 1,\n })\n .getOne()\n }\n\n /**\n * Finds first entity that matches given id.\n * If entity was not found in the database - returns null.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById<Entity>(\n entityClass: EntityTarget<Entity>,\n id: number | string | Date | ObjectID,\n ): Promise<Entity | null> {\n const metadata = this.connection.getMetadata(entityClass)\n\n // create query builder and apply find options\n return this.createQueryBuilder<Entity>(entityClass, metadata.name)\n .setFindOptions({\n take: 1,\n })\n .whereInIds(metadata.ensureEntityIdMap(id))\n .getOne()\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail<Entity>(\n entityClass: EntityTarget<Entity>,\n options: FindOneOptions<Entity>,\n ): Promise<Entity> {\n return this.findOne<Entity>(entityClass as any, options).then(\n (value) => {\n if (value === null) {\n return Promise.reject(\n new EntityNotFoundError(entityClass, options),\n )\n }\n return Promise.resolve(value)\n },\n )\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail<Entity>(\n entityClass: EntityTarget<Entity>,\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity> {\n return this.findOneBy<Entity>(entityClass as any, where).then(\n (value) => {\n if (value === null) {\n return Promise.reject(\n new EntityNotFoundError(entityClass, where),\n )\n }\n return Promise.resolve(value)\n },\n )\n }\n\n /**\n * Clears all the data from the given table (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n async clear<Entity>(entityClass: EntityTarget<Entity>): Promise<void> {\n const metadata = this.connection.getMetadata(entityClass)\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n try {\n return await queryRunner.clearTable(metadata.tablePath) // await is needed here because we are using finally\n } finally {\n if (!this.queryRunner) await queryRunner.release()\n }\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n async increment<Entity>(\n entityClass: EntityTarget<Entity>,\n conditions: any,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.findColumnWithPropertyPath(propertyPath)\n if (!column)\n throw new TypeORMError(\n `Column ${propertyPath} was not found in ${metadata.targetName} entity.`,\n )\n\n if (isNaN(Number(value)))\n throw new TypeORMError(`Value \"${value}\" is not a number.`)\n\n // convert possible embeded path \"social.likes\" into object { social: { like: () => value } }\n const values: QueryDeepPartialEntity<Entity> = propertyPath\n .split(\".\")\n .reduceRight(\n (value, key) => ({ [key]: value } as any),\n () =>\n this.connection.driver.escape(column.databaseName) +\n \" + \" +\n value,\n )\n\n return this.createQueryBuilder<Entity>(entityClass as any, \"entity\")\n .update(entityClass)\n .set(values)\n .where(conditions)\n .execute()\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n async decrement<Entity>(\n entityClass: EntityTarget<Entity>,\n conditions: any,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n const metadata = this.connection.getMetadata(entityClass)\n const column = metadata.findColumnWithPropertyPath(propertyPath)\n if (!column)\n throw new TypeORMError(\n `Column ${propertyPath} was not found in ${metadata.targetName} entity.`,\n )\n\n if (isNaN(Number(value)))\n throw new TypeORMError(`Value \"${value}\" is not a number.`)\n\n // convert possible embeded path \"social.likes\" into object { social: { like: () => value } }\n const values: QueryDeepPartialEntity<Entity> = propertyPath\n .split(\".\")\n .reduceRight(\n (value, key) => ({ [key]: value } as any),\n () =>\n this.connection.driver.escape(column.databaseName) +\n \" - \" +\n value,\n )\n\n return this.createQueryBuilder<Entity>(entityClass as any, \"entity\")\n .update(entityClass)\n .set(values)\n .where(conditions)\n .execute()\n }\n\n /**\n * Gets repository for the given entity class or name.\n * If single database connection mode is used, then repository is obtained from the\n * repository aggregator, where each repository is individually created for this entity manager.\n * When single database connection is not used, repository is being obtained from the connection.\n */\n getRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): Repository<Entity> {\n // find already created repository instance and return it if found\n const repository = this.repositories.find(\n (repository) => repository.target === target,\n )\n if (repository) return repository\n\n // if repository was not found then create it, store its instance and return it\n if (this.connection.driver.options.type === \"mongodb\") {\n const newRepository = new MongoRepository(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.push(newRepository as any)\n return newRepository\n } else {\n const newRepository = new Repository<any>(\n target,\n this,\n this.queryRunner,\n )\n this.repositories.push(newRepository)\n return newRepository\n }\n }\n\n /**\n * Gets tree repository for the given entity class or name.\n * If single database connection mode is used, then repository is obtained from the\n * repository aggregator, where each repository is individually created for this entity manager.\n * When single database connection is not used, repository is being obtained from the connection.\n */\n getTreeRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): TreeRepository<Entity> {\n // tree tables aren't supported by some drivers (mongodb)\n if (this.connection.driver.treeSupport === false)\n throw new TreeRepositoryNotSupportedError(this.connection.driver)\n\n // find already created repository instance and return it if found\n const repository = this.treeRepositories.find(\n (repository) => repository.target === target,\n )\n if (repository) return repository\n\n // check if repository is real tree repository\n const newRepository = new TreeRepository(target, this, this.queryRunner)\n this.treeRepositories.push(newRepository)\n return newRepository\n }\n\n /**\n * Gets mongodb repository for the given entity class.\n */\n getMongoRepository<Entity extends ObjectLiteral>(\n target: EntityTarget<Entity>,\n ): MongoRepository<Entity> {\n return this.connection.getMongoRepository<Entity>(target)\n }\n\n /**\n * Creates a new repository instance out of a given Repository and\n * sets current EntityManager instance to it. Used to work with custom repositories\n * in transactions.\n */\n withRepository<Entity extends ObjectLiteral, R extends Repository<Entity>>(\n repository: R,\n ): R {\n const repositoryConstructor =\n repository.constructor as typeof Repository\n const { target, manager, queryRunner, ...otherRepositoryProperties } =\n repository\n return Object.assign(\n new repositoryConstructor(repository.target, this) as R,\n {\n ...otherRepositoryProperties,\n },\n )\n }\n\n /**\n * Gets custom entity repository marked with @EntityRepository decorator.\n *\n * @deprecated use Repository.extend to create custom repositories\n */\n getCustomRepository<T>(customRepository: ObjectType<T>): T {\n const entityRepositoryMetadataArgs =\n getMetadataArgsStorage().entityRepositories.find((repository) => {\n return (\n repository.target ===\n (typeof customRepository === \"function\"\n ? customRepository\n : (customRepository as any).constructor)\n )\n })\n if (!entityRepositoryMetadataArgs)\n throw new CustomRepositoryNotFoundError(customRepository)\n\n const entityMetadata = entityRepositoryMetadataArgs.entity\n ? this.connection.getMetadata(entityRepositoryMetadataArgs.entity)\n : undefined\n const entityRepositoryInstance =\n new (entityRepositoryMetadataArgs.target as any)(\n this,\n entityMetadata,\n )\n\n // NOTE: dynamic access to protected properties. We need this to prevent unwanted properties in those classes to be exposed,\n // however we need these properties for internal work of the class\n if (entityRepositoryInstance instanceof AbstractRepository) {\n if (!(entityRepositoryInstance as any)[\"manager\"])\n (entityRepositoryInstance as any)[\"manager\"] = this\n } else {\n if (!entityMetadata)\n throw new CustomRepositoryCannotInheritRepositoryError(\n customRepository,\n )\n ;(entityRepositoryInstance as any)[\"manager\"] = this\n ;(entityRepositoryInstance as any)[\"metadata\"] = entityMetadata\n }\n\n return entityRepositoryInstance\n }\n\n /**\n * Releases all resources used by entity manager.\n * This is used when entity manager is created with a single query runner,\n * and this single query runner needs to be released after job with entity manager is done.\n */\n async release(): Promise<void> {\n if (!this.queryRunner) throw new NoNeedToReleaseEntityManagerError()\n\n return this.queryRunner.release()\n }\n}\n"],"sourceRoot":".."}
@@ -287,7 +287,7 @@ export declare class MongoEntityManager extends EntityManager {
287
287
  * Overrides cursor's toArray and next methods to convert results to entity automatically.
288
288
  */
289
289
  protected applyEntityTransformationToCursor<Entity extends ObjectLiteral>(metadata: EntityMetadata, cursor: Cursor<Entity> | AggregationCursor<Entity>): void;
290
- protected filterSoftDeleted<Entity>(cursor: Cursor<Entity>, deleteDateColumn: ColumnMetadata, query?: ObjectLiteral): void;
290
+ protected filterSoftDeleted<Entity>(cursor: Cursor<Entity>, deleteDateColumn: ColumnMetadata): void;
291
291
  /**
292
292
  * Finds first entity that matches given conditions and/or find options.
293
293
  */
@@ -92,11 +92,11 @@ class MongoEntityManager extends EntityManager_1.EntityManager {
92
92
  if (optionsOrConditions.order)
93
93
  cursor.sort(this.convertFindOptionsOrderToOrderCriteria(optionsOrConditions.order));
94
94
  if (deleteDateColumn && !optionsOrConditions.withDeleted) {
95
- this.filterSoftDeleted(cursor, deleteDateColumn, query);
95
+ this.filterSoftDeleted(cursor, deleteDateColumn);
96
96
  }
97
97
  }
98
98
  else if (deleteDateColumn) {
99
- this.filterSoftDeleted(cursor, deleteDateColumn, query);
99
+ this.filterSoftDeleted(cursor, deleteDateColumn);
100
100
  }
101
101
  return await cursor.toArray();
102
102
  }
@@ -633,15 +633,8 @@ class MongoEntityManager extends EntityManager_1.EntityManager {
633
633
  }
634
634
  };
635
635
  }
636
- filterSoftDeleted(cursor, deleteDateColumn, query) {
637
- const { $or, ...restQuery } = query !== null && query !== void 0 ? query : {};
638
- cursor.filter({
639
- $or: [
640
- { [deleteDateColumn.propertyName]: { $eq: null } },
641
- ...(Array.isArray($or) ? $or : []),
642
- ],
643
- ...restQuery,
644
- });
636
+ filterSoftDeleted(cursor, deleteDateColumn) {
637
+ cursor.filter({ $where: `this.${deleteDateColumn.propertyName}==null` });
645
638
  }
646
639
  /**
647
640
  * Finds first entity that matches given conditions and/or find options.
@@ -666,11 +659,11 @@ class MongoEntityManager extends EntityManager_1.EntityManager {
666
659
  if (findOneOptionsOrConditions.order)
667
660
  cursor.sort(this.convertFindOptionsOrderToOrderCriteria(findOneOptionsOrConditions.order));
668
661
  if (deleteDateColumn && !findOneOptionsOrConditions.withDeleted) {
669
- this.filterSoftDeleted(cursor, deleteDateColumn, query);
662
+ this.filterSoftDeleted(cursor, deleteDateColumn);
670
663
  }
671
664
  }
672
665
  else if (deleteDateColumn) {
673
- this.filterSoftDeleted(cursor, deleteDateColumn, query);
666
+ this.filterSoftDeleted(cursor, deleteDateColumn);
674
667
  }
675
668
  // const result = await cursor.limit(1).next();
676
669
  const result = await cursor.limit(1).toArray();
@@ -690,11 +683,11 @@ class MongoEntityManager extends EntityManager_1.EntityManager {
690
683
  if (optionsOrConditions.order)
691
684
  cursor.sort(this.convertFindOptionsOrderToOrderCriteria(optionsOrConditions.order));
692
685
  if (deleteDateColumn && !optionsOrConditions.withDeleted) {
693
- this.filterSoftDeleted(cursor, deleteDateColumn, query);
686
+ this.filterSoftDeleted(cursor, deleteDateColumn);
694
687
  }
695
688
  }
696
689
  else if (deleteDateColumn) {
697
- this.filterSoftDeleted(cursor, deleteDateColumn, query);
690
+ this.filterSoftDeleted(cursor, deleteDateColumn);
698
691
  }
699
692
  return cursor.toArray();
700
693
  }
@@ -715,11 +708,11 @@ class MongoEntityManager extends EntityManager_1.EntityManager {
715
708
  if (optionsOrConditions.order)
716
709
  cursor.sort(this.convertFindOptionsOrderToOrderCriteria(optionsOrConditions.order));
717
710
  if (deleteDateColumn && !optionsOrConditions.withDeleted) {
718
- this.filterSoftDeleted(cursor, deleteDateColumn, query);
711
+ this.filterSoftDeleted(cursor, deleteDateColumn);
719
712
  }
720
713
  }
721
714
  else if (deleteDateColumn) {
722
- this.filterSoftDeleted(cursor, deleteDateColumn, query);
715
+ this.filterSoftDeleted(cursor, deleteDateColumn);
723
716
  }
724
717
  const [results, count] = await Promise.all([
725
718
  cursor.toArray(),