typeorm 0.2.40-dev.969af95 → 0.2.40-dev.e80f97d

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 (91) hide show
  1. package/browser/driver/Driver.d.ts +5 -0
  2. package/browser/driver/Driver.js.map +1 -1
  3. package/browser/driver/aurora-data-api/AuroraDataApiDriver.d.ts +4 -0
  4. package/browser/driver/aurora-data-api/AuroraDataApiDriver.js +4 -0
  5. package/browser/driver/aurora-data-api/AuroraDataApiDriver.js.map +1 -1
  6. package/browser/driver/cockroachdb/CockroachDriver.d.ts +4 -0
  7. package/browser/driver/cockroachdb/CockroachDriver.js +4 -0
  8. package/browser/driver/cockroachdb/CockroachDriver.js.map +1 -1
  9. package/browser/driver/mysql/MysqlDriver.d.ts +4 -0
  10. package/browser/driver/mysql/MysqlDriver.js +4 -0
  11. package/browser/driver/mysql/MysqlDriver.js.map +1 -1
  12. package/browser/driver/postgres/PostgresDriver.d.ts +4 -0
  13. package/browser/driver/postgres/PostgresDriver.js +4 -0
  14. package/browser/driver/postgres/PostgresDriver.js.map +1 -1
  15. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.d.ts +4 -0
  16. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +4 -0
  17. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
  18. package/browser/driver/types/UpsertType.d.ts +1 -0
  19. package/browser/driver/types/UpsertType.js +3 -0
  20. package/browser/driver/types/UpsertType.js.map +1 -0
  21. package/browser/entity-manager/EntityManager.d.ts +2 -0
  22. package/browser/entity-manager/EntityManager.js +42 -1
  23. package/browser/entity-manager/EntityManager.js.map +1 -1
  24. package/browser/find-options/FindConditions.d.ts +6 -2
  25. package/browser/find-options/FindConditions.js.map +1 -1
  26. package/browser/metadata/EntityMetadata.d.ts +4 -0
  27. package/browser/metadata/EntityMetadata.js +14 -0
  28. package/browser/metadata/EntityMetadata.js.map +1 -1
  29. package/browser/query-builder/InsertQueryBuilder.js +8 -2
  30. package/browser/query-builder/InsertQueryBuilder.js.map +1 -1
  31. package/browser/query-builder/SelectQueryBuilder.d.ts +1 -1
  32. package/browser/query-builder/SelectQueryBuilder.js +4 -20
  33. package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
  34. package/browser/repository/BaseEntity.d.ts +7 -0
  35. package/browser/repository/BaseEntity.js +8 -0
  36. package/browser/repository/BaseEntity.js.map +1 -1
  37. package/browser/repository/Repository.d.ts +7 -0
  38. package/browser/repository/Repository.js +8 -0
  39. package/browser/repository/Repository.js.map +1 -1
  40. package/browser/repository/UpsertOptions.d.ts +6 -0
  41. package/browser/repository/UpsertOptions.js +3 -0
  42. package/browser/repository/UpsertOptions.js.map +1 -0
  43. package/browser/util/OrmUtils.d.ts +1 -0
  44. package/browser/util/OrmUtils.js +11 -0
  45. package/browser/util/OrmUtils.js.map +1 -1
  46. package/driver/Driver.d.ts +5 -0
  47. package/driver/Driver.js.map +1 -1
  48. package/driver/aurora-data-api/AuroraDataApiDriver.d.ts +4 -0
  49. package/driver/aurora-data-api/AuroraDataApiDriver.js +4 -0
  50. package/driver/aurora-data-api/AuroraDataApiDriver.js.map +1 -1
  51. package/driver/cockroachdb/CockroachDriver.d.ts +4 -0
  52. package/driver/cockroachdb/CockroachDriver.js +4 -0
  53. package/driver/cockroachdb/CockroachDriver.js.map +1 -1
  54. package/driver/mysql/MysqlDriver.d.ts +4 -0
  55. package/driver/mysql/MysqlDriver.js +4 -0
  56. package/driver/mysql/MysqlDriver.js.map +1 -1
  57. package/driver/postgres/PostgresDriver.d.ts +4 -0
  58. package/driver/postgres/PostgresDriver.js +4 -0
  59. package/driver/postgres/PostgresDriver.js.map +1 -1
  60. package/driver/sqlite-abstract/AbstractSqliteDriver.d.ts +4 -0
  61. package/driver/sqlite-abstract/AbstractSqliteDriver.js +4 -0
  62. package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
  63. package/driver/types/UpsertType.d.ts +1 -0
  64. package/driver/types/UpsertType.js +4 -0
  65. package/driver/types/UpsertType.js.map +1 -0
  66. package/entity-manager/EntityManager.d.ts +2 -0
  67. package/entity-manager/EntityManager.js +41 -0
  68. package/entity-manager/EntityManager.js.map +1 -1
  69. package/find-options/FindConditions.d.ts +6 -2
  70. package/find-options/FindConditions.js.map +1 -1
  71. package/metadata/EntityMetadata.d.ts +4 -0
  72. package/metadata/EntityMetadata.js +14 -0
  73. package/metadata/EntityMetadata.js.map +1 -1
  74. package/package.json +1 -1
  75. package/query-builder/InsertQueryBuilder.js +11 -5
  76. package/query-builder/InsertQueryBuilder.js.map +1 -1
  77. package/query-builder/SelectQueryBuilder.d.ts +1 -1
  78. package/query-builder/SelectQueryBuilder.js +4 -20
  79. package/query-builder/SelectQueryBuilder.js.map +1 -1
  80. package/repository/BaseEntity.d.ts +7 -0
  81. package/repository/BaseEntity.js +8 -0
  82. package/repository/BaseEntity.js.map +1 -1
  83. package/repository/Repository.d.ts +7 -0
  84. package/repository/Repository.js +8 -0
  85. package/repository/Repository.js.map +1 -1
  86. package/repository/UpsertOptions.d.ts +6 -0
  87. package/repository/UpsertOptions.js +4 -0
  88. package/repository/UpsertOptions.js.map +1 -0
  89. package/util/OrmUtils.d.ts +1 -0
  90. package/util/OrmUtils.js +11 -0
  91. package/util/OrmUtils.js.map +1 -1
@@ -13,6 +13,7 @@ import { UpdateResult } from "../query-builder/result/UpdateResult";
13
13
  import { DeleteResult } from "../query-builder/result/DeleteResult";
14
14
  import { ObjectID } from "../driver/mongodb/typings";
15
15
  import { QueryDeepPartialEntity } from "../query-builder/QueryPartialEntity";
16
+ import { UpsertOptions } from "./UpsertOptions";
16
17
  /**
17
18
  * Base abstract entity for all entities, used in ActiveRecord patterns.
18
19
  */
@@ -142,6 +143,12 @@ export declare class BaseEntity {
142
143
  * Does not check if entity exist in the database.
143
144
  */
144
145
  static update<T extends BaseEntity>(this: ObjectType<T>, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<T>, partialEntity: QueryDeepPartialEntity<T>, options?: SaveOptions): Promise<UpdateResult>;
146
+ /**
147
+ * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
148
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
149
+ * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
150
+ */
151
+ static upsert<T extends BaseEntity>(this: ObjectType<T> & typeof BaseEntity, entityOrEntities: QueryDeepPartialEntity<T> | (QueryDeepPartialEntity<T>[]), conflictPathsOrOptions: string[] | UpsertOptions<T>): Promise<InsertResult>;
145
152
  /**
146
153
  * Deletes entities by a given criteria.
147
154
  * Unlike remove method executes a primitive operation without cascades, relations and other operations included.
@@ -174,6 +174,14 @@ var BaseEntity = /** @class */ (function () {
174
174
  BaseEntity.update = function (criteria, partialEntity, options) {
175
175
  return this.getRepository().update(criteria, partialEntity, options);
176
176
  };
177
+ /**
178
+ * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
179
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
180
+ * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
181
+ */
182
+ BaseEntity.upsert = function (entityOrEntities, conflictPathsOrOptions) {
183
+ return this.getRepository().upsert(entityOrEntities, conflictPathsOrOptions);
184
+ };
177
185
  /**
178
186
  * Deletes entities by a given criteria.
179
187
  * Unlike remove method executes a primitive operation without cascades, relations and other operations included.
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/repository/BaseEntity.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAczC,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAGhD;;GAEG;AACH;IAAA;IAwXA,CAAC;IA5WG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,0BAAK,GAAL;QACI,OAAQ,IAAI,CAAC,WAAmB,CAAC,aA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C;IAcD;;;OAGG;IACI,oBAAS,GAAhB,UAA4D,GAAU,EAAE,mBAA0D;QAC9H,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,mBAA0B,CAAC,CAAC;IACpF,CAAC;IAiBD;;OAEG;IACI,kBAAO,GAAd,UAA0D,mBAAqF,EAAE,YAAgC;QAC7K,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,mBAA0B,EAAE,YAAY,CAAC,CAAC;IAC3F,CAAC;IAiBD;;OAEG;IACI,wBAAa,GAApB,UAAgE,mBAAqF,EAAE,YAAgC;QACnL,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,aAAa,CAAC,mBAA0B,EAAE,YAAY,CAAC,CAAC;IACjG,CAAC;IAED;;;OAGG;IACI,gBAAK,GAAZ,UAAwD,KAAa,EAAE,UAAkB;QACrF,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACI,gBAAK,GAAZ;QACI,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC;IACjD,CAAC;IAEL,iBAAC;AAAD,CAxXA,AAwXC,IAAA","file":"BaseEntity.js","sourcesContent":["import {Repository} from \"./Repository\";\nimport {getConnection} from \"../globals\";\nimport {FindConditions} from \"../find-options/FindConditions\";\nimport {DeepPartial} from \"../common/DeepPartial\";\nimport {SaveOptions} from \"./SaveOptions\";\nimport {FindOneOptions} from \"../find-options/FindOneOptions\";\nimport {RemoveOptions} from \"./RemoveOptions\";\nimport {FindManyOptions} from \"../find-options/FindManyOptions\";\nimport {Connection} from \"../connection/Connection\";\nimport {ObjectType} from \"../common/ObjectType\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {InsertResult} from \"../query-builder/result/InsertResult\";\nimport {UpdateResult} from \"../query-builder/result/UpdateResult\";\nimport {DeleteResult} from \"../query-builder/result/DeleteResult\";\nimport {ObjectID} from \"../driver/mongodb/typings\";\nimport {ObjectUtils} from \"../util/ObjectUtils\";\nimport {QueryDeepPartialEntity} from \"../query-builder/QueryPartialEntity\";\n\n/**\n * Base abstract entity for all entities, used in ActiveRecord patterns.\n */\nexport class BaseEntity {\n\n // -------------------------------------------------------------------------\n // Private Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used in all static methods of the BaseEntity.\n */\n // @ts-ignore: Unused variable which is actually used\n private static usedConnection?: Connection;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(): boolean {\n return (this.constructor as any).getRepository().hasId(this);\n }\n\n /**\n * Saves current entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().save(this, options);\n }\n\n /**\n * Removes current entity from the database.\n */\n remove(options?: RemoveOptions): Promise<this> {\n return (this.constructor as any).getRepository().remove(this, options);\n }\n\n /**\n * Records the delete date of current entity.\n */\n softRemove(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().softRemove(this, options);\n }\n\n /**\n * Recovers a given entity in the database.\n */\n recover(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().recover(this, options);\n }\n\n /**\n * Reloads entity data from the database.\n */\n async reload(): Promise<void> {\n const base: any = this.constructor;\n const newestEntity: BaseEntity = await base.getRepository().findOneOrFail(base.getId(this));\n\n ObjectUtils.assign(this, newestEntity);\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Sets connection to be used by entity.\n */\n static useConnection(connection: Connection) {\n this.usedConnection = connection;\n }\n\n /**\n * Gets current entity's Repository.\n */\n static getRepository<T extends BaseEntity>(this: ObjectType<T>): Repository<T> {\n const connection: Connection = (this as any).usedConnection || getConnection();\n return connection.getRepository<T>(this);\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n static get target(): Function|string {\n return this.getRepository().target;\n }\n\n /**\n * Checks entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n static hasId(entity: BaseEntity): boolean {\n return this.getRepository().hasId(entity);\n }\n\n /**\n * Gets entity mixed id.\n */\n static getId<T extends BaseEntity>(this: ObjectType<T>, entity: T): any {\n return (this as any).getRepository().getId(entity);\n }\n\n /**\n * Creates a new query builder that can be used to build a sql query.\n */\n static createQueryBuilder<T extends BaseEntity>(this: ObjectType<T>, alias?: string): SelectQueryBuilder<T> {\n return (this as any).getRepository().createQueryBuilder(alias);\n }\n\n /**\n * Creates a new entity instance.\n */\n static create<T extends BaseEntity>(this: ObjectType<T>): T;\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 static create<T extends BaseEntity>(this: ObjectType<T>, entityLikeArray: DeepPartial<T>[]): T[];\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 static create<T extends BaseEntity>(this: ObjectType<T>, entityLike: DeepPartial<T>): T;\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 static create<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities?: any): T {\n return (this as any).getRepository().create(entityOrEntities);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n static merge<T extends BaseEntity>(this: ObjectType<T>, mergeIntoEntity: T, ...entityLikes: DeepPartial<T>[]): T {\n return (this as any).getRepository().merge(mergeIntoEntity, ...entityLikes);\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 * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n static preload<T extends BaseEntity>(this: ObjectType<T>, entityLike: DeepPartial<T>): Promise<T|undefined> {\n return (this as any).getRepository().preload(entityLike);\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 static save<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: SaveOptions): 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 static save<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: SaveOptions): Promise<T>;\n\n /**\n * Saves one or many given entities.\n */\n static save<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return (this as any).getRepository().save(entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: RemoveOptions): Promise<T[]>;\n\n /**\n * Removes a given entity from the database.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: RemoveOptions): Promise<T>;\n\n /**\n * Removes one or many given entities.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: RemoveOptions): Promise<T|T[]> {\n return (this as any).getRepository().remove(entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: SaveOptions): Promise<T[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: SaveOptions): Promise<T>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return (this as any).getRepository().softRemove(entityOrEntities as any, options);\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 */\n static insert<T extends BaseEntity>(this: ObjectType<T>, entity: QueryDeepPartialEntity<T>|QueryDeepPartialEntity<T>[], options?: SaveOptions): Promise<InsertResult> {\n return (this as any).getRepository().insert(entity, options);\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\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 */\n static update<T extends BaseEntity>(this: ObjectType<T>, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<T>, partialEntity: QueryDeepPartialEntity<T>, options?: SaveOptions): Promise<UpdateResult> {\n return (this as any).getRepository().update(criteria, partialEntity, options);\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike remove 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 */\n static delete<T extends BaseEntity>(this: ObjectType<T>, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<T>, options?: RemoveOptions): Promise<DeleteResult> {\n return (this as any).getRepository().delete(criteria, options);\n }\n\n /**\n * Counts entities that match given options.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<number> {\n return (this as any).getRepository().count(optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<T[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<T[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<T[]> {\n return (this as any).getRepository().find(optionsOrConditions as any);\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 static findAndCount<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<[ T[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<[ T[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<[ T[], number ]> {\n return (this as any).getRepository().findAndCount(optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], options?: FindManyOptions<T>): Promise<T[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], conditions?: FindConditions<T>): Promise<T[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<T[]> {\n return (this as any).getRepository().findByIds(ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, id?: string|number|Date|ObjectID, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<T>|FindConditions<T>, maybeOptions?: FindOneOptions<T>): Promise<T|undefined> {\n return (this as any).getRepository().findOne(optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, id?: string|number|Date|ObjectID, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given options.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<T>|FindConditions<T>, maybeOptions?: FindOneOptions<T>): Promise<T> {\n return (this as any).getRepository().findOneOrFail(optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n static query<T extends BaseEntity>(this: ObjectType<T>, query: string, parameters?: any[]): Promise<any> {\n return (this as any).getRepository().query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n */\n static clear<T extends BaseEntity>(this: ObjectType<T>, ): Promise<void> {\n return (this as any).getRepository().clear();\n }\n\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/repository/BaseEntity.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAczC,OAAO,EAA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AAQ,IAAY,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,mBAA0B,CAAC,CAAC;IAC3E,CAAC;IAYD;;OAEG;IACI,eAAI,GAAX,UAAuD,mBAA0D;QAC7G,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,mBAA0B,CAAC,CAAC;IAC1E,CAAC;IAgBD;;;;OAIG;IACI,uBAAY,GAAnB,UAA+D,mBAA0D;QACrH,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,YAAY,CAAC,mBAA0B,CAAC,CAAC;IAClF,CAAC;IAcD;;;OAGG;IACI,oBAAS,GAAhB,UAA4D,GAAU,EAAE,mBAA0D;QAC9H,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,mBAA0B,CAAC,CAAC;IACpF,CAAC;IAiBD;;OAEG;IACI,kBAAO,GAAd,UAA0D,mBAAqF,EAAE,YAAgC;QAC7K,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,mBAA0B,EAAE,YAAY,CAAC,CAAC;IAC3F,CAAC;IAiBD;;OAEG;IACI,wBAAa,GAApB,UAAgE,mBAAqF,EAAE,YAAgC;QACnL,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,aAAa,CAAC,mBAA0B,EAAE,YAAY,CAAC,CAAC;IACjG,CAAC;IAED;;;OAGG;IACI,gBAAK,GAAZ,UAAwD,KAAa,EAAE,UAAkB;QACrF,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACI,gBAAK,GAAZ;QACI,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC;IACjD,CAAC;IAEL,iBAAC;AAAD,CAnYA,AAmYC,IAAA","file":"BaseEntity.js","sourcesContent":["import {Repository} from \"./Repository\";\nimport {getConnection} from \"../globals\";\nimport {FindConditions} from \"../find-options/FindConditions\";\nimport {DeepPartial} from \"../common/DeepPartial\";\nimport {SaveOptions} from \"./SaveOptions\";\nimport {FindOneOptions} from \"../find-options/FindOneOptions\";\nimport {RemoveOptions} from \"./RemoveOptions\";\nimport {FindManyOptions} from \"../find-options/FindManyOptions\";\nimport {Connection} from \"../connection/Connection\";\nimport {ObjectType} from \"../common/ObjectType\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {InsertResult} from \"../query-builder/result/InsertResult\";\nimport {UpdateResult} from \"../query-builder/result/UpdateResult\";\nimport {DeleteResult} from \"../query-builder/result/DeleteResult\";\nimport {ObjectID} from \"../driver/mongodb/typings\";\nimport {ObjectUtils} from \"../util/ObjectUtils\";\nimport {QueryDeepPartialEntity} from \"../query-builder/QueryPartialEntity\";\nimport {UpsertOptions} from \"./UpsertOptions\";\n\n/**\n * Base abstract entity for all entities, used in ActiveRecord patterns.\n */\nexport class BaseEntity {\n\n // -------------------------------------------------------------------------\n // Private Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used in all static methods of the BaseEntity.\n */\n // @ts-ignore: Unused variable which is actually used\n private static usedConnection?: Connection;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(): boolean {\n return (this.constructor as any).getRepository().hasId(this);\n }\n\n /**\n * Saves current entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().save(this, options);\n }\n\n /**\n * Removes current entity from the database.\n */\n remove(options?: RemoveOptions): Promise<this> {\n return (this.constructor as any).getRepository().remove(this, options);\n }\n\n /**\n * Records the delete date of current entity.\n */\n softRemove(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().softRemove(this, options);\n }\n\n /**\n * Recovers a given entity in the database.\n */\n recover(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().recover(this, options);\n }\n\n /**\n * Reloads entity data from the database.\n */\n async reload(): Promise<void> {\n const base: any = this.constructor;\n const newestEntity: BaseEntity = await base.getRepository().findOneOrFail(base.getId(this));\n\n ObjectUtils.assign(this, newestEntity);\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Sets connection to be used by entity.\n */\n static useConnection(connection: Connection) {\n this.usedConnection = connection;\n }\n\n /**\n * Gets current entity's Repository.\n */\n static getRepository<T extends BaseEntity>(this: ObjectType<T>): Repository<T> {\n const connection: Connection = (this as any).usedConnection || getConnection();\n return connection.getRepository<T>(this);\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n static get target(): Function|string {\n return this.getRepository().target;\n }\n\n /**\n * Checks entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n static hasId(entity: BaseEntity): boolean {\n return this.getRepository().hasId(entity);\n }\n\n /**\n * Gets entity mixed id.\n */\n static getId<T extends BaseEntity>(this: ObjectType<T>, entity: T): any {\n return (this as any).getRepository().getId(entity);\n }\n\n /**\n * Creates a new query builder that can be used to build a sql query.\n */\n static createQueryBuilder<T extends BaseEntity>(this: ObjectType<T>, alias?: string): SelectQueryBuilder<T> {\n return (this as any).getRepository().createQueryBuilder(alias);\n }\n\n /**\n * Creates a new entity instance.\n */\n static create<T extends BaseEntity>(this: ObjectType<T>): T;\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 static create<T extends BaseEntity>(this: ObjectType<T>, entityLikeArray: DeepPartial<T>[]): T[];\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 static create<T extends BaseEntity>(this: ObjectType<T>, entityLike: DeepPartial<T>): T;\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 static create<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities?: any): T {\n return (this as any).getRepository().create(entityOrEntities);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n static merge<T extends BaseEntity>(this: ObjectType<T>, mergeIntoEntity: T, ...entityLikes: DeepPartial<T>[]): T {\n return (this as any).getRepository().merge(mergeIntoEntity, ...entityLikes);\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 * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n static preload<T extends BaseEntity>(this: ObjectType<T>, entityLike: DeepPartial<T>): Promise<T|undefined> {\n return (this as any).getRepository().preload(entityLike);\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 static save<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: SaveOptions): 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 static save<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: SaveOptions): Promise<T>;\n\n /**\n * Saves one or many given entities.\n */\n static save<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return (this as any).getRepository().save(entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: RemoveOptions): Promise<T[]>;\n\n /**\n * Removes a given entity from the database.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: RemoveOptions): Promise<T>;\n\n /**\n * Removes one or many given entities.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: RemoveOptions): Promise<T|T[]> {\n return (this as any).getRepository().remove(entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: SaveOptions): Promise<T[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: SaveOptions): Promise<T>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return (this as any).getRepository().softRemove(entityOrEntities as any, options);\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 */\n static insert<T extends BaseEntity>(this: ObjectType<T>, entity: QueryDeepPartialEntity<T>|QueryDeepPartialEntity<T>[], options?: SaveOptions): Promise<InsertResult> {\n return (this as any).getRepository().insert(entity, options);\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\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 */\n static update<T extends BaseEntity>(this: ObjectType<T>, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<T>, partialEntity: QueryDeepPartialEntity<T>, options?: SaveOptions): Promise<UpdateResult> {\n return (this as any).getRepository().update(criteria, partialEntity, options);\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n static upsert<T extends BaseEntity>(this: ObjectType<T> & typeof BaseEntity, \n entityOrEntities: QueryDeepPartialEntity<T> | (QueryDeepPartialEntity<T>[]),\n conflictPathsOrOptions: string[] | UpsertOptions<T>): Promise<InsertResult> {\n return this.getRepository<T>().upsert(entityOrEntities, conflictPathsOrOptions);\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike remove 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 */\n static delete<T extends BaseEntity>(this: ObjectType<T>, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<T>, options?: RemoveOptions): Promise<DeleteResult> {\n return (this as any).getRepository().delete(criteria, options);\n }\n\n /**\n * Counts entities that match given options.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<number> {\n return (this as any).getRepository().count(optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<T[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<T[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<T[]> {\n return (this as any).getRepository().find(optionsOrConditions as any);\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 static findAndCount<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<[ T[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<[ T[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<[ T[], number ]> {\n return (this as any).getRepository().findAndCount(optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], options?: FindManyOptions<T>): Promise<T[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], conditions?: FindConditions<T>): Promise<T[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<T[]> {\n return (this as any).getRepository().findByIds(ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, id?: string|number|Date|ObjectID, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<T>|FindConditions<T>, maybeOptions?: FindOneOptions<T>): Promise<T|undefined> {\n return (this as any).getRepository().findOne(optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, id?: string|number|Date|ObjectID, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given options.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<T>|FindConditions<T>, maybeOptions?: FindOneOptions<T>): Promise<T> {\n return (this as any).getRepository().findOneOrFail(optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n static query<T extends BaseEntity>(this: ObjectType<T>, query: string, parameters?: any[]): Promise<any> {\n return (this as any).getRepository().query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n */\n static clear<T extends BaseEntity>(this: ObjectType<T>, ): Promise<void> {\n return (this as any).getRepository().clear();\n }\n\n}\n"],"sourceRoot":".."}
@@ -14,6 +14,7 @@ import { InsertResult } from "../query-builder/result/InsertResult";
14
14
  import { QueryDeepPartialEntity } from "../query-builder/QueryPartialEntity";
15
15
  import { ObjectID } from "../driver/mongodb/typings";
16
16
  import { FindConditions } from "../find-options/FindConditions";
17
+ import { UpsertOptions } from "./UpsertOptions";
17
18
  /**
18
19
  * Repository is supposed to work with your entity objects. Find entities, insert, update, delete, etc.
19
20
  */
@@ -163,6 +164,12 @@ export declare class Repository<Entity extends ObjectLiteral> {
163
164
  * Does not check if entity exist in the database.
164
165
  */
165
166
  update(criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult>;
167
+ /**
168
+ * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
169
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
170
+ * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
171
+ */
172
+ upsert(entityOrEntities: QueryDeepPartialEntity<Entity> | (QueryDeepPartialEntity<Entity>[]), conflictPathsOrOptions: string[] | UpsertOptions<Entity>): Promise<InsertResult>;
166
173
  /**
167
174
  * Deletes entities by a given criteria.
168
175
  * Unlike save method executes a primitive operation without cascades, relations and other operations included.
@@ -111,6 +111,14 @@ var Repository = /** @class */ (function () {
111
111
  Repository.prototype.update = function (criteria, partialEntity) {
112
112
  return this.manager.update(this.metadata.target, criteria, partialEntity);
113
113
  };
114
+ /**
115
+ * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
116
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
117
+ * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
118
+ */
119
+ Repository.prototype.upsert = function (entityOrEntities, conflictPathsOrOptions) {
120
+ return this.manager.upsert(this.metadata.target, entityOrEntities, conflictPathsOrOptions);
121
+ };
114
122
  /**
115
123
  * Deletes entities by a given criteria.
116
124
  * Unlike save method executes a primitive operation without cascades, relations and other operations included.
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/repository/Repository.ts"],"names":[],"mappings":";AAiBA;;GAEG;AACH;IAAA;IAsZA,CAAC;IAjYG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,uCAAkB,GAAlB,UAAmB,KAAc,EAAE,WAAyB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAS,IAAI,CAAC,QAAQ,CAAC,MAAa,EAAE,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IACpJ,CAAC;IAOD,sBAAI,8BAAM;QALV;;;;WAIG;aACH;YACI,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAChC,CAAC;;;OAAA;IAED;;;OAGG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,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KG;IACH,0BAAK,GAAL;QACI,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,8BAAS,GAAT,UAAU,UAAkC,EAAE,YAAoB,EAAE,KAAsB;QACtF,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAED;;OAEG;IACH,8BAAS,GAAT,UAAU,UAAkC,EAAE,YAAoB,EAAE,KAAsB;QACtF,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAEL,iBAAC;AAAD,CAtZA,AAsZC,IAAA","file":"Repository.js","sourcesContent":["import {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {FindManyOptions} from \"../find-options/FindManyOptions\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {FindOneOptions} from \"../find-options/FindOneOptions\";\nimport {DeepPartial} from \"../common/DeepPartial\";\nimport {SaveOptions} from \"./SaveOptions\";\nimport {RemoveOptions} from \"./RemoveOptions\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {DeleteResult} from \"../query-builder/result/DeleteResult\";\nimport {UpdateResult} from \"../query-builder/result/UpdateResult\";\nimport {InsertResult} from \"../query-builder/result/InsertResult\";\nimport {QueryDeepPartialEntity} from \"../query-builder/QueryPartialEntity\";\nimport {ObjectID} from \"../driver/mongodb/typings\";\nimport {FindConditions} from \"../find-options/FindConditions\";\n\n/**\n * Repository is supposed to work with your entity objects. Find entities, insert, update, delete, etc.\n */\nexport class Repository<Entity extends ObjectLiteral> {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: EntityManager;\n\n /**\n * Entity metadata of the entity current repository manages.\n */\n readonly metadata: EntityMetadata;\n\n /**\n * Query runner provider used for this repository.\n */\n readonly queryRunner?: QueryRunner;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new query builder that can be used to build a sql query.\n */\n createQueryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {\n return this.manager.createQueryBuilder<Entity>(this.metadata.target as any, alias || this.metadata.targetName, queryRunner || this.queryRunner);\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n get target(): Function|string {\n return this.metadata.target;\n }\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(entity: Entity): boolean {\n return this.manager.hasId(this.metadata.target, entity);\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: Entity): any {\n return this.manager.getId(this.metadata.target, entity);\n }\n\n /**\n * Creates a new entity instance.\n */\n create(): Entity;\n\n /**\n * Creates new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLikeArray: DeepPartial<Entity>[]): Entity[];\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 are present in entity schema.\n */\n create(entityLike: DeepPartial<Entity>): 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(plainEntityLikeOrPlainEntityLikes?: DeepPartial<Entity>|DeepPartial<Entity>[]): Entity|Entity[] {\n return this.manager.create<any>(this.metadata.target as any, plainEntityLikeOrPlainEntityLikes as any);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n merge(mergeIntoEntity: Entity, ...entityLikes: DeepPartial<Entity>[]): Entity {\n return this.manager.merge(this.metadata.target as any, mergeIntoEntity, ...entityLikes);\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 * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n preload(entityLike: DeepPartial<Entity>): Promise<Entity|undefined> {\n return this.manager.preload(this.metadata.target as any, entityLike);\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<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): 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<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): 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<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): 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<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Saves one or many given entities.\n */\n save<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.save<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n remove(entities: Entity[], options?: RemoveOptions): Promise<Entity[]>;\n\n /**\n * Removes a given entity from the database.\n */\n remove(entity: Entity, options?: RemoveOptions): Promise<Entity>;\n\n /**\n * Removes one or many given entities.\n */\n remove(entityOrEntities: Entity|Entity[], options?: RemoveOptions): Promise<Entity|Entity[]> {\n return this.manager.remove(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.softRemove<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Recovers one or many given entities.\n */\n recover<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.recover<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\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 */\n insert(entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[])): Promise<InsertResult> {\n return this.manager.insert(this.metadata.target as any, entity);\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\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 */\n update(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult> {\n return this.manager.update(this.metadata.target as any, criteria as any, partialEntity);\n }\n\n /**\n * Deletes entities by a given criteria.\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 */\n delete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<DeleteResult> {\n return this.manager.delete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Records the delete date of entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n softDelete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.softDelete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Restores entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n restore(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.restore(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Counts entities that match given options.\n */\n count(options?: FindManyOptions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n count(conditions?: FindConditions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n count(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<number> {\n return this.manager.count(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n find(options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n find(conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.find(this.metadata.target as any, optionsOrConditions as any);\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(options?: FindManyOptions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(conditions?: FindConditions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<[ Entity[], number ]> {\n return this.manager.findAndCount(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n findByIds(ids: any[], conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target as any, ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity|undefined> {\n return this.manager.findOne(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n query(query: string, parameters?: any[]): Promise<any> {\n return this.manager.query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (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 clear(): Promise<void> {\n return this.manager.clear(this.metadata.target);\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n increment(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.increment(this.metadata.target, conditions, propertyPath, value);\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n decrement(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.decrement(this.metadata.target, conditions, propertyPath, value);\n }\n\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"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,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAEL,iBAAC;AAAD,CAjaA,AAiaC,IAAA","file":"Repository.js","sourcesContent":["import {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {FindManyOptions} from \"../find-options/FindManyOptions\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {FindOneOptions} from \"../find-options/FindOneOptions\";\nimport {DeepPartial} from \"../common/DeepPartial\";\nimport {SaveOptions} from \"./SaveOptions\";\nimport {RemoveOptions} from \"./RemoveOptions\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {DeleteResult} from \"../query-builder/result/DeleteResult\";\nimport {UpdateResult} from \"../query-builder/result/UpdateResult\";\nimport {InsertResult} from \"../query-builder/result/InsertResult\";\nimport {QueryDeepPartialEntity} from \"../query-builder/QueryPartialEntity\";\nimport {ObjectID} from \"../driver/mongodb/typings\";\nimport {FindConditions} from \"../find-options/FindConditions\";\nimport {UpsertOptions} from \"./UpsertOptions\";\n\n/**\n * Repository is supposed to work with your entity objects. Find entities, insert, update, delete, etc.\n */\nexport class Repository<Entity extends ObjectLiteral> {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: EntityManager;\n\n /**\n * Entity metadata of the entity current repository manages.\n */\n readonly metadata: EntityMetadata;\n\n /**\n * Query runner provider used for this repository.\n */\n readonly queryRunner?: QueryRunner;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new query builder that can be used to build a sql query.\n */\n createQueryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {\n return this.manager.createQueryBuilder<Entity>(this.metadata.target as any, alias || this.metadata.targetName, queryRunner || this.queryRunner);\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n get target(): Function|string {\n return this.metadata.target;\n }\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(entity: Entity): boolean {\n return this.manager.hasId(this.metadata.target, entity);\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: Entity): any {\n return this.manager.getId(this.metadata.target, entity);\n }\n\n /**\n * Creates a new entity instance.\n */\n create(): Entity;\n\n /**\n * Creates new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLikeArray: DeepPartial<Entity>[]): Entity[];\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 are present in entity schema.\n */\n create(entityLike: DeepPartial<Entity>): 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(plainEntityLikeOrPlainEntityLikes?: DeepPartial<Entity>|DeepPartial<Entity>[]): Entity|Entity[] {\n return this.manager.create<any>(this.metadata.target as any, plainEntityLikeOrPlainEntityLikes as any);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n merge(mergeIntoEntity: Entity, ...entityLikes: DeepPartial<Entity>[]): Entity {\n return this.manager.merge(this.metadata.target as any, mergeIntoEntity, ...entityLikes);\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 * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n preload(entityLike: DeepPartial<Entity>): Promise<Entity|undefined> {\n return this.manager.preload(this.metadata.target as any, entityLike);\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<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): 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<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): 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<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): 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<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Saves one or many given entities.\n */\n save<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.save<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n remove(entities: Entity[], options?: RemoveOptions): Promise<Entity[]>;\n\n /**\n * Removes a given entity from the database.\n */\n remove(entity: Entity, options?: RemoveOptions): Promise<Entity>;\n\n /**\n * Removes one or many given entities.\n */\n remove(entityOrEntities: Entity|Entity[], options?: RemoveOptions): Promise<Entity|Entity[]> {\n return this.manager.remove(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.softRemove<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Recovers one or many given entities.\n */\n recover<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.recover<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\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 */\n insert(entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[])): Promise<InsertResult> {\n return this.manager.insert(this.metadata.target as any, entity);\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\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 */\n update(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult> {\n return this.manager.update(this.metadata.target as any, criteria as any, partialEntity);\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n upsert(\n entityOrEntities: QueryDeepPartialEntity<Entity> | (QueryDeepPartialEntity<Entity>[]),\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>): Promise<InsertResult> {\n return this.manager.upsert(this.metadata.target as any, entityOrEntities, conflictPathsOrOptions);\n }\n\n /**\n * Deletes entities by a given criteria.\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 */\n delete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<DeleteResult> {\n return this.manager.delete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Records the delete date of entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n softDelete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.softDelete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Restores entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n restore(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.restore(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Counts entities that match given options.\n */\n count(options?: FindManyOptions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n count(conditions?: FindConditions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n count(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<number> {\n return this.manager.count(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n find(options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n find(conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.find(this.metadata.target as any, optionsOrConditions as any);\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(options?: FindManyOptions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(conditions?: FindConditions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<[ Entity[], number ]> {\n return this.manager.findAndCount(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n findByIds(ids: any[], conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target as any, ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity|undefined> {\n return this.manager.findOne(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n query(query: string, parameters?: any[]): Promise<any> {\n return this.manager.query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (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 clear(): Promise<void> {\n return this.manager.clear(this.metadata.target);\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n increment(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.increment(this.metadata.target, conditions, propertyPath, value);\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n decrement(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.decrement(this.metadata.target, conditions, propertyPath, value);\n }\n\n}\n"],"sourceRoot":".."}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Special options passed to Repository#upsert
3
+ */
4
+ export interface UpsertOptions<Entity> {
5
+ conflictPaths: string[];
6
+ }
@@ -0,0 +1,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=UpsertOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../browser/src/repository/UpsertOptions.ts"],"names":[],"mappings":"","file":"UpsertOptions.js","sourcesContent":["/**\n * Special options passed to Repository#upsert\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface UpsertOptions<Entity> {\n conflictPaths: string[]\n}\n"],"sourceRoot":".."}
@@ -41,5 +41,6 @@ export declare class OrmUtils {
41
41
  * Compares two arrays.
42
42
  */
43
43
  static isArraysEqual(arr1: any[], arr2: any[]): boolean;
44
+ static areMutuallyExclusive<T>(...lists: T[][]): boolean;
44
45
  private static compare2Objects;
45
46
  }
@@ -226,6 +226,17 @@ var OrmUtils = /** @class */ (function () {
226
226
  return arr2.indexOf(element) !== -1;
227
227
  });
228
228
  };
229
+ OrmUtils.areMutuallyExclusive = function () {
230
+ var lists = [];
231
+ for (var _i = 0; _i < arguments.length; _i++) {
232
+ lists[_i] = arguments[_i];
233
+ }
234
+ var haveSharedObjects = lists.some(function (list) {
235
+ var otherLists = lists.filter(function (otherList) { return otherList !== list; });
236
+ return list.some(function (item) { return otherLists.some(function (otherList) { return otherList.includes(item); }); });
237
+ });
238
+ return !haveSharedObjects;
239
+ };
229
240
  // -------------------------------------------------------------------------
230
241
  // Private methods
231
242
  // -------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/util/OrmUtils.ts"],"names":[],"mappings":";AAEA;IAAA;IAiVA,CAAC;IA/UG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACI,cAAK,GAAZ,UAAgB,KAAU,EAAE,IAAY;QACpC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,EAAE,UAAC,CAAC,EAAE,CAAC;YAC1D,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG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AAC;oBAClB,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBAEnB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;wBAC1D,OAAO,KAAK,CAAC;qBAChB;oBAED,SAAS,CAAC,GAAG,EAAE,CAAC;oBAChB,UAAU,CAAC,GAAG,EAAE,CAAC;oBACjB,MAAM;gBAEV;oBACI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;wBACf,OAAO,KAAK,CAAC;qBAChB;oBACD,MAAM;aACb;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEL,eAAC;AAAD,CAjVA,AAiVC,IAAA","file":"OrmUtils.js","sourcesContent":["import {ObjectLiteral} from \"../common/ObjectLiteral\";\n\nexport class OrmUtils {\n\n // -------------------------------------------------------------------------\n // Public methods\n // -------------------------------------------------------------------------\n\n /**\n * Chunks array into pieces.\n */\n static chunk<T>(array: T[], size: number): T[][] {\n return Array.from(Array(Math.ceil(array.length / size)), (_, i) => {\n return array.slice(i * size, i * size + size);\n });\n }\n\n static splitClassesAndStrings<T>(clsesAndStrings: (string | T)[]): [T[], string[]] {\n return [\n (clsesAndStrings).filter((cls): cls is T => typeof cls !== \"string\"),\n (clsesAndStrings).filter((str): str is string => typeof str === \"string\"),\n ];\n }\n\n static groupBy<T, R>(array: T[], propertyCallback: (item: T) => R): { id: R, items: T[] }[] {\n return array.reduce((groupedArray, value) => {\n const key = propertyCallback(value);\n let grouped = groupedArray.find(i => i.id === key);\n if (!grouped) {\n grouped = { id: key, items: [] };\n groupedArray.push(grouped);\n }\n grouped.items.push(value);\n return groupedArray;\n }, [] as Array<{ id: R, items: T[] }>);\n }\n\n static uniq<T>(array: T[], criteria?: (item: T) => any): T[];\n static uniq<T, K extends keyof T>(array: T[], property: K): T[];\n static uniq<T, K extends keyof T>(array: T[], criteriaOrProperty?: ((item: T) => any) | K): T[] {\n return array.reduce((uniqueArray, item) => {\n let found: boolean = false;\n if (criteriaOrProperty instanceof Function) {\n const itemValue = criteriaOrProperty(item);\n found = !!uniqueArray.find(uniqueItem => criteriaOrProperty(uniqueItem) === itemValue);\n\n } else if (typeof criteriaOrProperty === \"string\") {\n found = !!uniqueArray.find(uniqueItem => uniqueItem[criteriaOrProperty] === item[criteriaOrProperty]);\n\n } else {\n found = uniqueArray.indexOf(item) !== -1;\n }\n\n if (!found)\n uniqueArray.push(item);\n\n return uniqueArray;\n }, [] as T[]);\n }\n\n // Checks if it's an object made by Object.create(null), {} or new Object()\n private static isPlainObject(item: any) {\n if (item === null || item === undefined) {\n return false;\n }\n\n return !item.constructor || item.constructor === Object;\n }\n\n private static mergeArrayKey(target: any, key: number, value: any, memo: Map<any, any>) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n target[key] = memo.get(value);\n return;\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return;\n }\n\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n target[key] = value;\n return;\n }\n\n if (!target[key]) {\n target[key] = Array.isArray(value) ? [] : {};\n }\n\n memo.set(value, target[key]);\n this.merge(target[key], value, memo);\n memo.delete(value);\n }\n\n private static mergeObjectKey(target: any, key: string, value: any, memo: Map<any, any>) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n Object.assign(target, { [key]: memo.get(value) });\n return;\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return;\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n Object.assign(target, { [key]: value });\n return;\n }\n\n if (!target[key]) {\n Object.assign(target, { [key]: Array.isArray(value) ? [] : {} });\n }\n\n memo.set(value, target[key]);\n this.merge(target[key], value, memo);\n memo.delete(value);\n }\n\n private static merge(target: any, source: any, memo: Map<any, any> = new Map()): any {\n if (this.isPlainObject(target) && this.isPlainObject(source)) {\n for (const key of Object.keys(source)) {\n this.mergeObjectKey(target, key, source[key], memo);\n }\n }\n\n if (Array.isArray(target) && Array.isArray(source)) {\n for (let key = 0; key < source.length; key++) {\n this.mergeArrayKey(target, key, source[key], memo);\n }\n }\n }\n\n /**\n * Deep Object.assign.\n */\n static mergeDeep(target: any, ...sources: any[]): any {\n if (!sources.length) {\n return target;\n }\n\n for (const source of sources) {\n OrmUtils.merge(target, source);\n }\n\n return target;\n }\n\n /**\n * Deep compare objects.\n *\n * @see http://stackoverflow.com/a/1144249\n */\n static deepCompare(...args: any[]): boolean {\n let i: any, l: any, leftChain: any, rightChain: any;\n\n if (arguments.length < 1) {\n return true; // Die silently? Don't know how to handle such case, please help...\n // throw \"Need two or more arguments to compare\";\n }\n\n for (i = 1, l = arguments.length; i < l; i++) {\n\n leftChain = []; // Todo: this can be cached\n rightChain = [];\n\n if (!this.compare2Objects(leftChain, rightChain, arguments[0], arguments[i])) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Check if two entity-id-maps are the same\n */\n static compareIds(firstId: ObjectLiteral|undefined, secondId: ObjectLiteral|undefined): boolean {\n if (firstId === undefined || firstId === null || secondId === undefined || secondId === null)\n return false;\n\n // Optimized version for the common case\n if (\n ((typeof firstId.id === \"string\" && typeof secondId.id === \"string\") ||\n (typeof firstId.id === \"number\" && typeof secondId.id === \"number\")) &&\n Object.keys(firstId).length === 1 &&\n Object.keys(secondId).length === 1\n ) {\n return firstId.id === secondId.id;\n }\n\n return OrmUtils.deepCompare(firstId, secondId);\n }\n\n /**\n * Transforms given value into boolean value.\n */\n static toBoolean(value: any): boolean {\n if (typeof value === \"boolean\")\n return value;\n\n if (typeof value === \"string\")\n return value === \"true\" || value === \"1\";\n\n if (typeof value === \"number\")\n return value > 0;\n\n return false;\n }\n\n /**\n * Composes an object from the given array of keys and values.\n */\n static zipObject(keys: any[], values: any[]): ObjectLiteral {\n return keys.reduce((object, column, index) => {\n object[column] = values[index];\n return object;\n }, {} as ObjectLiteral);\n }\n\n /**\n * Compares two arrays.\n */\n static isArraysEqual(arr1: any[], arr2: any[]): boolean {\n if (arr1.length !== arr2.length) return false;\n return arr1.every(element => {\n return arr2.indexOf(element) !== -1;\n });\n }\n\n // -------------------------------------------------------------------------\n // Private methods\n // -------------------------------------------------------------------------\n\n private static compare2Objects(leftChain: any, rightChain: any, x: any, y: any) {\n let p;\n\n // remember that NaN === NaN returns false\n // and isNaN(undefined) returns true\n if (Number.isNaN(x) && Number.isNaN(y))\n return true;\n\n // Compare primitives and functions.\n // Check if both arguments link to the same object.\n // Especially useful on the step where we compare prototypes\n if (x === y)\n return true;\n\n // Unequal, but either is null or undefined (use case: jsonb comparasion)\n // PR #3776, todo: add tests\n if (x === null || y === null || x === undefined || y === undefined)\n return false;\n\n // Fix the buffer compare bug.\n // See: https://github.com/typeorm/typeorm/issues/3654\n if ((typeof x.equals === \"function\" || x.equals instanceof Function) && x.equals(y))\n return true;\n\n // Works in case when functions are created in constructor.\n // Comparing dates is a common scenario. Another built-ins?\n // We can even handle functions passed across iframes\n if ((typeof x === \"function\" && typeof y === \"function\") ||\n (x instanceof Date && y instanceof Date) ||\n (x instanceof RegExp && y instanceof RegExp) ||\n (x instanceof String && y instanceof String) ||\n (x instanceof Number && y instanceof Number))\n return x.toString() === y.toString();\n\n // At last checking prototypes as good as we can\n if (!(x instanceof Object && y instanceof Object))\n return false;\n\n if (x.isPrototypeOf(y) || y.isPrototypeOf(x))\n return false;\n\n if (x.constructor !== y.constructor)\n return false;\n\n if (x.prototype !== y.prototype)\n return false;\n\n // Check for infinitive linking loops\n if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1)\n return false;\n\n // Quick checking of one object being a subset of another.\n // todo: cache the structure of arguments[0] for performance\n for (p in y) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false;\n }\n else if (typeof y[p] !== typeof x[p]) {\n return false;\n }\n }\n\n for (p in x) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false;\n }\n else if (typeof y[p] !== typeof x[p]) {\n return false;\n }\n\n switch (typeof (x[p])) {\n case \"object\":\n case \"function\":\n\n leftChain.push(x);\n rightChain.push(y);\n\n if (!this.compare2Objects(leftChain, rightChain, x[p], y[p])) {\n return false;\n }\n\n leftChain.pop();\n rightChain.pop();\n break;\n\n default:\n if (x[p] !== y[p]) {\n return false;\n }\n break;\n }\n }\n\n return true;\n }\n\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/util/OrmUtils.ts"],"names":[],"mappings":";AAEA;IAAA;IAyVA,CAAC;IAvVG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACI,cAAK,GAAZ,UAAgB,KAAU,EAAE,IAAY;QACpC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,EAAE,UAAC,CAAC,EAAE,CAAC;YAC1D,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,+BAAsB,GAA7B,UAAiC,eAA+B;QAC5D,OAAO;YACH,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,IAAe,OAAA,OAAO,GAAG,KAAK,QAAQ,EAAvB,CAAuB,CAAC;YACpE,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,IAAoB,OAAA,OAAO,GAAG,KAAK,QAAQ,EAAvB,CAAuB,CAAC;SAC5E,CAAC;IACN,CAAC;IAEM,gBAAO,GAAd,UAAqB,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,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;gBACnB,KAAK,QAAQ,CAAC;gBACd,KAAK,UAAU;oBAEX,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBAClB,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBAEnB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;wBAC1D,OAAO,KAAK,CAAC;qBAChB;oBAED,SAAS,CAAC,GAAG,EAAE,CAAC;oBAChB,UAAU,CAAC,GAAG,EAAE,CAAC;oBACjB,MAAM;gBAEV;oBACI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;wBACf,OAAO,KAAK,CAAC;qBAChB;oBACD,MAAM;aACb;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEL,eAAC;AAAD,CAzVA,AAyVC,IAAA","file":"OrmUtils.js","sourcesContent":["import {ObjectLiteral} from \"../common/ObjectLiteral\";\n\nexport class OrmUtils {\n\n // -------------------------------------------------------------------------\n // Public methods\n // -------------------------------------------------------------------------\n\n /**\n * Chunks array into pieces.\n */\n static chunk<T>(array: T[], size: number): T[][] {\n return Array.from(Array(Math.ceil(array.length / size)), (_, i) => {\n return array.slice(i * size, i * size + size);\n });\n }\n\n static splitClassesAndStrings<T>(clsesAndStrings: (string | T)[]): [T[], string[]] {\n return [\n (clsesAndStrings).filter((cls): cls is T => typeof cls !== \"string\"),\n (clsesAndStrings).filter((str): str is string => typeof str === \"string\"),\n ];\n }\n\n static groupBy<T, R>(array: T[], propertyCallback: (item: T) => R): { id: R, items: T[] }[] {\n return array.reduce((groupedArray, value) => {\n const key = propertyCallback(value);\n let grouped = groupedArray.find(i => i.id === key);\n if (!grouped) {\n grouped = { id: key, items: [] };\n groupedArray.push(grouped);\n }\n grouped.items.push(value);\n return groupedArray;\n }, [] as Array<{ id: R, items: T[] }>);\n }\n\n static uniq<T>(array: T[], criteria?: (item: T) => any): T[];\n static uniq<T, K extends keyof T>(array: T[], property: K): T[];\n static uniq<T, K extends keyof T>(array: T[], criteriaOrProperty?: ((item: T) => any) | K): T[] {\n return array.reduce((uniqueArray, item) => {\n let found: boolean = false;\n if (criteriaOrProperty instanceof Function) {\n const itemValue = criteriaOrProperty(item);\n found = !!uniqueArray.find(uniqueItem => criteriaOrProperty(uniqueItem) === itemValue);\n\n } else if (typeof criteriaOrProperty === \"string\") {\n found = !!uniqueArray.find(uniqueItem => uniqueItem[criteriaOrProperty] === item[criteriaOrProperty]);\n\n } else {\n found = uniqueArray.indexOf(item) !== -1;\n }\n\n if (!found)\n uniqueArray.push(item);\n\n return uniqueArray;\n }, [] as T[]);\n }\n\n // Checks if it's an object made by Object.create(null), {} or new Object()\n private static isPlainObject(item: any) {\n if (item === null || item === undefined) {\n return false;\n }\n\n return !item.constructor || item.constructor === Object;\n }\n\n private static mergeArrayKey(target: any, key: number, value: any, memo: Map<any, any>) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n target[key] = memo.get(value);\n return;\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return;\n }\n\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n target[key] = value;\n return;\n }\n\n if (!target[key]) {\n target[key] = Array.isArray(value) ? [] : {};\n }\n\n memo.set(value, target[key]);\n this.merge(target[key], value, memo);\n memo.delete(value);\n }\n\n private static mergeObjectKey(target: any, key: string, value: any, memo: Map<any, any>) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n Object.assign(target, { [key]: memo.get(value) });\n return;\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return;\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n Object.assign(target, { [key]: value });\n return;\n }\n\n if (!target[key]) {\n Object.assign(target, { [key]: Array.isArray(value) ? [] : {} });\n }\n\n memo.set(value, target[key]);\n this.merge(target[key], value, memo);\n memo.delete(value);\n }\n\n private static merge(target: any, source: any, memo: Map<any, any> = new Map()): any {\n if (this.isPlainObject(target) && this.isPlainObject(source)) {\n for (const key of Object.keys(source)) {\n this.mergeObjectKey(target, key, source[key], memo);\n }\n }\n\n if (Array.isArray(target) && Array.isArray(source)) {\n for (let key = 0; key < source.length; key++) {\n this.mergeArrayKey(target, key, source[key], memo);\n }\n }\n }\n\n /**\n * Deep Object.assign.\n */\n static mergeDeep(target: any, ...sources: any[]): any {\n if (!sources.length) {\n return target;\n }\n\n for (const source of sources) {\n OrmUtils.merge(target, source);\n }\n\n return target;\n }\n\n /**\n * Deep compare objects.\n *\n * @see http://stackoverflow.com/a/1144249\n */\n static deepCompare(...args: any[]): boolean {\n let i: any, l: any, leftChain: any, rightChain: any;\n\n if (arguments.length < 1) {\n return true; // Die silently? Don't know how to handle such case, please help...\n // throw \"Need two or more arguments to compare\";\n }\n\n for (i = 1, l = arguments.length; i < l; i++) {\n\n leftChain = []; // Todo: this can be cached\n rightChain = [];\n\n if (!this.compare2Objects(leftChain, rightChain, arguments[0], arguments[i])) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Check if two entity-id-maps are the same\n */\n static compareIds(firstId: ObjectLiteral|undefined, secondId: ObjectLiteral|undefined): boolean {\n if (firstId === undefined || firstId === null || secondId === undefined || secondId === null)\n return false;\n\n // Optimized version for the common case\n if (\n ((typeof firstId.id === \"string\" && typeof secondId.id === \"string\") ||\n (typeof firstId.id === \"number\" && typeof secondId.id === \"number\")) &&\n Object.keys(firstId).length === 1 &&\n Object.keys(secondId).length === 1\n ) {\n return firstId.id === secondId.id;\n }\n\n return OrmUtils.deepCompare(firstId, secondId);\n }\n\n /**\n * Transforms given value into boolean value.\n */\n static toBoolean(value: any): boolean {\n if (typeof value === \"boolean\")\n return value;\n\n if (typeof value === \"string\")\n return value === \"true\" || value === \"1\";\n\n if (typeof value === \"number\")\n return value > 0;\n\n return false;\n }\n\n /**\n * Composes an object from the given array of keys and values.\n */\n static zipObject(keys: any[], values: any[]): ObjectLiteral {\n return keys.reduce((object, column, index) => {\n object[column] = values[index];\n return object;\n }, {} as ObjectLiteral);\n }\n\n /**\n * Compares two arrays.\n */\n static isArraysEqual(arr1: any[], arr2: any[]): boolean {\n if (arr1.length !== arr2.length) return false;\n return arr1.every(element => {\n return arr2.indexOf(element) !== -1;\n });\n }\n\n static areMutuallyExclusive<T>(...lists: T[][]): boolean {\n const haveSharedObjects = lists.some(list => {\n const otherLists = lists.filter(otherList => otherList !== list);\n return list.some(item => otherLists.some(otherList => otherList.includes(item)));\n });\n return !haveSharedObjects;\n }\n\n // -------------------------------------------------------------------------\n // Private methods\n // -------------------------------------------------------------------------\n\n private static compare2Objects(leftChain: any, rightChain: any, x: any, y: any) {\n let p;\n\n // remember that NaN === NaN returns false\n // and isNaN(undefined) returns true\n if (Number.isNaN(x) && Number.isNaN(y))\n return true;\n\n // Compare primitives and functions.\n // Check if both arguments link to the same object.\n // Especially useful on the step where we compare prototypes\n if (x === y)\n return true;\n\n // Unequal, but either is null or undefined (use case: jsonb comparasion)\n // PR #3776, todo: add tests\n if (x === null || y === null || x === undefined || y === undefined)\n return false;\n\n // Fix the buffer compare bug.\n // See: https://github.com/typeorm/typeorm/issues/3654\n if ((typeof x.equals === \"function\" || x.equals instanceof Function) && x.equals(y))\n return true;\n\n // Works in case when functions are created in constructor.\n // Comparing dates is a common scenario. Another built-ins?\n // We can even handle functions passed across iframes\n if ((typeof x === \"function\" && typeof y === \"function\") ||\n (x instanceof Date && y instanceof Date) ||\n (x instanceof RegExp && y instanceof RegExp) ||\n (x instanceof String && y instanceof String) ||\n (x instanceof Number && y instanceof Number))\n return x.toString() === y.toString();\n\n // At last checking prototypes as good as we can\n if (!(x instanceof Object && y instanceof Object))\n return false;\n\n if (x.isPrototypeOf(y) || y.isPrototypeOf(x))\n return false;\n\n if (x.constructor !== y.constructor)\n return false;\n\n if (x.prototype !== y.prototype)\n return false;\n\n // Check for infinitive linking loops\n if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1)\n return false;\n\n // Quick checking of one object being a subset of another.\n // todo: cache the structure of arguments[0] for performance\n for (p in y) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false;\n }\n else if (typeof y[p] !== typeof x[p]) {\n return false;\n }\n }\n\n for (p in x) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false;\n }\n else if (typeof y[p] !== typeof x[p]) {\n return false;\n }\n\n switch (typeof (x[p])) {\n case \"object\":\n case \"function\":\n\n leftChain.push(x);\n rightChain.push(y);\n\n if (!this.compare2Objects(leftChain, rightChain, x[p], y[p])) {\n return false;\n }\n\n leftChain.pop();\n rightChain.pop();\n break;\n\n default:\n if (x[p] !== y[p]) {\n return false;\n }\n break;\n }\n }\n\n return true;\n }\n\n}\n"],"sourceRoot":".."}
@@ -12,6 +12,7 @@ import { ReplicationMode } from "./types/ReplicationMode";
12
12
  import { Table } from "../schema-builder/table/Table";
13
13
  import { View } from "../schema-builder/view/View";
14
14
  import { TableForeignKey } from "../schema-builder/table/TableForeignKey";
15
+ import { UpsertType } from "./types/UpsertType";
15
16
  /**
16
17
  * Driver organizes TypeORM communication with specific database management system.
17
18
  */
@@ -42,6 +43,10 @@ export interface Driver {
42
43
  * Gets list of supported column data types by a driver.
43
44
  */
44
45
  supportedDataTypes: ColumnType[];
46
+ /**
47
+ * Returns type of upsert supported by driver if any
48
+ */
49
+ supportedUpsertType?: UpsertType;
45
50
  /**
46
51
  * Default values of length, precision and scale depends on column data type.
47
52
  * Used in the cases when length/precision/scale is not specified by user.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/Driver.ts"],"names":[],"mappings":"","file":"Driver.js","sourcesContent":["import {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {ColumnMetadata} from \"../metadata/ColumnMetadata\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {ColumnType} from \"./types/ColumnTypes\";\nimport {MappedColumnTypes} from \"./types/MappedColumnTypes\";\nimport {SchemaBuilder} from \"../schema-builder/SchemaBuilder\";\nimport {DataTypeDefaults} from \"./types/DataTypeDefaults\";\nimport {BaseConnectionOptions} from \"../connection/BaseConnectionOptions\";\nimport {TableColumn} from \"../schema-builder/table/TableColumn\";\nimport {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {ReplicationMode} from \"./types/ReplicationMode\";\nimport { Table } from \"../schema-builder/table/Table\";\nimport { View } from \"../schema-builder/view/View\";\nimport { TableForeignKey } from \"../schema-builder/table/TableForeignKey\";\n\n/**\n * Driver organizes TypeORM communication with specific database management system.\n */\nexport interface Driver {\n\n /**\n * Connection options.\n */\n options: BaseConnectionOptions;\n\n /**\n * Database name used to perform all write queries.\n *\n * todo: probably move into query runner.\n */\n database?: string;\n\n /**\n * Schema name used to perform all write queries.\n */\n schema?: string;\n\n /**\n * Indicates if replication is enabled.\n */\n isReplicated: boolean;\n\n /**\n * Indicates if tree tables are supported by this driver.\n */\n treeSupport: boolean;\n\n /**\n * Gets list of supported column data types by a driver.\n */\n supportedDataTypes: ColumnType[];\n\n /**\n * Default values of length, precision and scale depends on column data type.\n * Used in the cases when length/precision/scale is not specified by user.\n */\n dataTypeDefaults: DataTypeDefaults;\n\n /**\n * Gets list of spatial column data types.\n */\n spatialTypes: ColumnType[];\n\n /**\n * Gets list of column data types that support length by a driver.\n */\n withLengthColumnTypes: ColumnType[];\n\n /**\n * Gets list of column data types that support precision by a driver.\n */\n withPrecisionColumnTypes: ColumnType[];\n\n /**\n * Gets list of column data types that support scale by a driver.\n */\n withScaleColumnTypes: ColumnType[];\n\n /**\n * Orm has special columns and we need to know what database column types should be for those types.\n * Column types are driver dependant.\n */\n mappedDataTypes: MappedColumnTypes;\n\n /**\n * Max length allowed by the DBMS for aliases (execution of queries).\n */\n maxAliasLength?: number;\n\n /**\n * Performs connection to the database.\n * Depend on driver type it may create a connection pool.\n */\n connect(): Promise<void>;\n\n /**\n * Makes any action after connection (e.g. create extensions in Postgres driver).\n */\n afterConnect(): Promise<void>;\n\n /**\n * Closes connection with database and releases all resources.\n */\n disconnect(): Promise<void>;\n\n /**\n * Synchronizes database schema (creates tables, indices, etc).\n */\n createSchemaBuilder(): SchemaBuilder;\n\n /**\n * Creates a query runner used for common queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner;\n\n /**\n * Replaces parameters in the given sql with special escaping character\n * and an array of parameter names to be passed to a query.\n */\n escapeQueryWithParameters(sql: string, parameters: ObjectLiteral, nativeParameters: ObjectLiteral): [string, any[]];\n\n /**\n * Escapes a table name, column name or an alias.\n *\n * todo: probably escape should be able to handle dots in the names and automatically escape them\n */\n escape(name: string): string;\n\n /**\n * Build full table name with database name, schema name and table name.\n * E.g. myDB.mySchema.myTable\n */\n buildTableName(tableName: string, schema?: string, database?: string): string;\n\n /**\n * Parse a target table name or other types and return a normalized table definition.\n */\n parseTableName(target: EntityMetadata | Table | View | TableForeignKey | string): { tableName: string, schema?: string, database?: string };\n\n /**\n * Prepares given value to a value to be persisted, based on its column type and metadata.\n */\n preparePersistentValue(value: any, column: ColumnMetadata): any;\n\n /**\n * Prepares given value to a value to be persisted, based on its column type.\n */\n prepareHydratedValue(value: any, column: ColumnMetadata): any;\n\n /**\n * Transforms type of the given column to a database column type.\n */\n normalizeType(column: { type?: ColumnType|string, length?: number|string, precision?: number|null, scale?: number, isArray?: boolean }): string;\n\n /**\n * Normalizes \"default\" value of the column.\n */\n normalizeDefault(columnMetadata: ColumnMetadata): string | undefined;\n\n /**\n * Normalizes \"isUnique\" value of the column.\n */\n normalizeIsUnique(column: ColumnMetadata): boolean;\n\n /**\n * Calculates column length taking into account the default length values.\n */\n getColumnLength(column: ColumnMetadata): string;\n\n /**\n * Normalizes \"default\" value of the column.\n */\n createFullType(column: TableColumn): string;\n\n /**\n * Obtains a new database connection to a master server.\n * Used for replication.\n * If replication is not setup then returns default connection's database connection.\n */\n obtainMasterConnection(): Promise<any>;\n\n /**\n * Obtains a new database connection to a slave server.\n * Used for replication.\n * If replication is not setup then returns master (default) connection's database connection.\n */\n obtainSlaveConnection(): Promise<any>;\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: any, entityIndex?: number, entityNum?: number): ObjectLiteral|undefined;\n\n /**\n * Differentiate columns of this table and columns from the given column metadatas columns\n * and returns only changed.\n */\n findChangedColumns(tableColumns: TableColumn[], columnMetadatas: ColumnMetadata[]): ColumnMetadata[];\n\n /**\n * Returns true if driver supports RETURNING / OUTPUT statement.\n */\n isReturningSqlSupported(): boolean;\n\n /**\n * Returns true if driver supports uuid values generation on its own.\n */\n isUUIDGenerationSupported(): boolean;\n\n /**\n * Returns true if driver supports fulltext indices.\n */\n isFullTextColumnTypeSupported(): boolean;\n\n /**\n * Creates an escaped parameter.\n */\n createParameter(parameterName: string, index: number): string;\n\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/driver/Driver.ts"],"names":[],"mappings":"","file":"Driver.js","sourcesContent":["import {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {ColumnMetadata} from \"../metadata/ColumnMetadata\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {ColumnType} from \"./types/ColumnTypes\";\nimport {MappedColumnTypes} from \"./types/MappedColumnTypes\";\nimport {SchemaBuilder} from \"../schema-builder/SchemaBuilder\";\nimport {DataTypeDefaults} from \"./types/DataTypeDefaults\";\nimport {BaseConnectionOptions} from \"../connection/BaseConnectionOptions\";\nimport {TableColumn} from \"../schema-builder/table/TableColumn\";\nimport {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {ReplicationMode} from \"./types/ReplicationMode\";\nimport { Table } from \"../schema-builder/table/Table\";\nimport { View } from \"../schema-builder/view/View\";\nimport { TableForeignKey } from \"../schema-builder/table/TableForeignKey\";\nimport { UpsertType } from \"./types/UpsertType\";\n\n/**\n * Driver organizes TypeORM communication with specific database management system.\n */\nexport interface Driver {\n\n /**\n * Connection options.\n */\n options: BaseConnectionOptions;\n\n /**\n * Database name used to perform all write queries.\n *\n * todo: probably move into query runner.\n */\n database?: string;\n\n /**\n * Schema name used to perform all write queries.\n */\n schema?: string;\n\n /**\n * Indicates if replication is enabled.\n */\n isReplicated: boolean;\n\n /**\n * Indicates if tree tables are supported by this driver.\n */\n treeSupport: boolean;\n\n /**\n * Gets list of supported column data types by a driver.\n */\n supportedDataTypes: ColumnType[];\n\n /**\n * Returns type of upsert supported by driver if any\n */\n supportedUpsertType?: UpsertType;\n\n /**\n * Default values of length, precision and scale depends on column data type.\n * Used in the cases when length/precision/scale is not specified by user.\n */\n dataTypeDefaults: DataTypeDefaults;\n\n /**\n * Gets list of spatial column data types.\n */\n spatialTypes: ColumnType[];\n\n /**\n * Gets list of column data types that support length by a driver.\n */\n withLengthColumnTypes: ColumnType[];\n\n /**\n * Gets list of column data types that support precision by a driver.\n */\n withPrecisionColumnTypes: ColumnType[];\n\n /**\n * Gets list of column data types that support scale by a driver.\n */\n withScaleColumnTypes: ColumnType[];\n\n /**\n * Orm has special columns and we need to know what database column types should be for those types.\n * Column types are driver dependant.\n */\n mappedDataTypes: MappedColumnTypes;\n\n /**\n * Max length allowed by the DBMS for aliases (execution of queries).\n */\n maxAliasLength?: number;\n\n /**\n * Performs connection to the database.\n * Depend on driver type it may create a connection pool.\n */\n connect(): Promise<void>;\n\n /**\n * Makes any action after connection (e.g. create extensions in Postgres driver).\n */\n afterConnect(): Promise<void>;\n\n /**\n * Closes connection with database and releases all resources.\n */\n disconnect(): Promise<void>;\n\n /**\n * Synchronizes database schema (creates tables, indices, etc).\n */\n createSchemaBuilder(): SchemaBuilder;\n\n /**\n * Creates a query runner used for common queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner;\n\n /**\n * Replaces parameters in the given sql with special escaping character\n * and an array of parameter names to be passed to a query.\n */\n escapeQueryWithParameters(sql: string, parameters: ObjectLiteral, nativeParameters: ObjectLiteral): [string, any[]];\n\n /**\n * Escapes a table name, column name or an alias.\n *\n * todo: probably escape should be able to handle dots in the names and automatically escape them\n */\n escape(name: string): string;\n\n /**\n * Build full table name with database name, schema name and table name.\n * E.g. myDB.mySchema.myTable\n */\n buildTableName(tableName: string, schema?: string, database?: string): string;\n\n /**\n * Parse a target table name or other types and return a normalized table definition.\n */\n parseTableName(target: EntityMetadata | Table | View | TableForeignKey | string): { tableName: string, schema?: string, database?: string };\n\n /**\n * Prepares given value to a value to be persisted, based on its column type and metadata.\n */\n preparePersistentValue(value: any, column: ColumnMetadata): any;\n\n /**\n * Prepares given value to a value to be persisted, based on its column type.\n */\n prepareHydratedValue(value: any, column: ColumnMetadata): any;\n\n /**\n * Transforms type of the given column to a database column type.\n */\n normalizeType(column: { type?: ColumnType|string, length?: number|string, precision?: number|null, scale?: number, isArray?: boolean }): string;\n\n /**\n * Normalizes \"default\" value of the column.\n */\n normalizeDefault(columnMetadata: ColumnMetadata): string | undefined;\n\n /**\n * Normalizes \"isUnique\" value of the column.\n */\n normalizeIsUnique(column: ColumnMetadata): boolean;\n\n /**\n * Calculates column length taking into account the default length values.\n */\n getColumnLength(column: ColumnMetadata): string;\n\n /**\n * Normalizes \"default\" value of the column.\n */\n createFullType(column: TableColumn): string;\n\n /**\n * Obtains a new database connection to a master server.\n * Used for replication.\n * If replication is not setup then returns default connection's database connection.\n */\n obtainMasterConnection(): Promise<any>;\n\n /**\n * Obtains a new database connection to a slave server.\n * Used for replication.\n * If replication is not setup then returns master (default) connection's database connection.\n */\n obtainSlaveConnection(): Promise<any>;\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: any, entityIndex?: number, entityNum?: number): ObjectLiteral|undefined;\n\n /**\n * Differentiate columns of this table and columns from the given column metadatas columns\n * and returns only changed.\n */\n findChangedColumns(tableColumns: TableColumn[], columnMetadatas: ColumnMetadata[]): ColumnMetadata[];\n\n /**\n * Returns true if driver supports RETURNING / OUTPUT statement.\n */\n isReturningSqlSupported(): boolean;\n\n /**\n * Returns true if driver supports uuid values generation on its own.\n */\n isUUIDGenerationSupported(): boolean;\n\n /**\n * Returns true if driver supports fulltext indices.\n */\n isFullTextColumnTypeSupported(): boolean;\n\n /**\n * Creates an escaped parameter.\n */\n createParameter(parameterName: string, index: number): string;\n\n}\n"],"sourceRoot":".."}
@@ -61,6 +61,10 @@ export declare class AuroraDataApiDriver implements Driver {
61
61
  * @see https://dev.mysql.com/doc/refman/8.0/en/data-types.html
62
62
  */
63
63
  supportedDataTypes: ColumnType[];
64
+ /**
65
+ * Returns type of upsert supported by driver if any
66
+ */
67
+ readonly supportedUpsertType = "on-duplicate-key-update";
64
68
  /**
65
69
  * Gets list of spatial column data types.
66
70
  */
@@ -93,6 +93,10 @@ var AuroraDataApiDriver = /** @class */ (function () {
93
93
  "multipolygon",
94
94
  "geometrycollection"
95
95
  ];
96
+ /**
97
+ * Returns type of upsert supported by driver if any
98
+ */
99
+ this.supportedUpsertType = "on-duplicate-key-update";
96
100
  /**
97
101
  * Gets list of spatial column data types.
98
102
  */