typeorm 0.2.41-dev.d494fcc → 0.2.42-dev.26815c6

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 (295) hide show
  1. package/README.md +38 -0
  2. package/browser/cache/RedisQueryResultCache.js +40 -35
  3. package/browser/cache/RedisQueryResultCache.js.map +1 -1
  4. package/browser/common/RelationType.d.ts +14 -0
  5. package/browser/common/RelationType.js +3 -0
  6. package/browser/common/RelationType.js.map +1 -0
  7. package/browser/connection/Connection.d.ts +3 -3
  8. package/browser/connection/Connection.js +46 -31
  9. package/browser/connection/Connection.js.map +1 -1
  10. package/browser/connection/ConnectionMetadataBuilder.d.ts +3 -3
  11. package/browser/connection/ConnectionMetadataBuilder.js +54 -22
  12. package/browser/connection/ConnectionMetadataBuilder.js.map +1 -1
  13. package/browser/connection/ConnectionOptionsReader.js +33 -28
  14. package/browser/connection/ConnectionOptionsReader.js.map +1 -1
  15. package/browser/decorator/Unique.d.ts +5 -4
  16. package/browser/decorator/Unique.js +7 -3
  17. package/browser/decorator/Unique.js.map +1 -1
  18. package/browser/decorator/columns/PrimaryGeneratedColumn.d.ts +2 -1
  19. package/browser/decorator/columns/PrimaryGeneratedColumn.js.map +1 -1
  20. package/browser/decorator/options/ColumnOptions.d.ts +4 -0
  21. package/browser/decorator/options/ColumnOptions.js.map +1 -1
  22. package/browser/decorator/options/PrimaryGeneratedColumnIdentityOptions.d.ts +22 -0
  23. package/browser/decorator/options/PrimaryGeneratedColumnIdentityOptions.js +3 -0
  24. package/browser/decorator/options/PrimaryGeneratedColumnIdentityOptions.js.map +1 -0
  25. package/browser/decorator/options/RelationOptions.d.ts +1 -1
  26. package/browser/decorator/options/RelationOptions.js.map +1 -1
  27. package/browser/decorator/options/UniqueOptions.d.ts +10 -0
  28. package/browser/decorator/options/UniqueOptions.js +3 -0
  29. package/browser/decorator/options/UniqueOptions.js.map +1 -0
  30. package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
  31. package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
  32. package/browser/driver/better-sqlite3/BetterSqlite3Driver.js +7 -5
  33. package/browser/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
  34. package/browser/driver/cockroachdb/CockroachQueryRunner.js +1 -1
  35. package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  36. package/browser/driver/mysql/MysqlQueryRunner.js +1 -1
  37. package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
  38. package/browser/driver/oracle/OracleQueryRunner.js +1 -1
  39. package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
  40. package/browser/driver/postgres/PostgresQueryRunner.js +14 -5
  41. package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
  42. package/browser/driver/sap/SapQueryRunner.js +1 -1
  43. package/browser/driver/sap/SapQueryRunner.js.map +1 -1
  44. package/browser/driver/sqlite/SqliteDriver.js +11 -10
  45. package/browser/driver/sqlite/SqliteDriver.js.map +1 -1
  46. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
  47. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  48. package/browser/driver/sqlserver/SqlServerQueryRunner.js +1 -1
  49. package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  50. package/browser/entity-manager/EntityManager.d.ts +2 -2
  51. package/browser/entity-manager/EntityManager.js +1 -1
  52. package/browser/entity-manager/EntityManager.js.map +1 -1
  53. package/browser/entity-manager/MongoEntityManager.js +2 -1
  54. package/browser/entity-manager/MongoEntityManager.js.map +1 -1
  55. package/browser/entity-schema/EntitySchemaOptions.d.ts +6 -0
  56. package/browser/entity-schema/EntitySchemaOptions.js.map +1 -1
  57. package/browser/entity-schema/EntitySchemaRelationOptions.d.ts +1 -1
  58. package/browser/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
  59. package/browser/entity-schema/EntitySchemaTransformer.js +3 -1
  60. package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
  61. package/browser/entity-schema/EntitySchemaUniqueOptions.d.ts +5 -0
  62. package/browser/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
  63. package/browser/find-options/operator/Like.d.ts +1 -1
  64. package/browser/find-options/operator/Like.js +1 -1
  65. package/browser/find-options/operator/Like.js.map +1 -1
  66. package/browser/globals.js +34 -7
  67. package/browser/globals.js.map +1 -1
  68. package/browser/index.d.ts +10 -0
  69. package/browser/index.js +10 -0
  70. package/browser/index.js.map +1 -1
  71. package/browser/metadata/ColumnMetadata.d.ts +4 -0
  72. package/browser/metadata/ColumnMetadata.js +2 -0
  73. package/browser/metadata/ColumnMetadata.js.map +1 -1
  74. package/browser/metadata/RelationMetadata.d.ts +1 -1
  75. package/browser/metadata/RelationMetadata.js.map +1 -1
  76. package/browser/metadata/UniqueMetadata.d.ts +5 -0
  77. package/browser/metadata/UniqueMetadata.js +1 -0
  78. package/browser/metadata/UniqueMetadata.js.map +1 -1
  79. package/browser/metadata-args/UniqueMetadataArgs.d.ts +5 -0
  80. package/browser/metadata-args/UniqueMetadataArgs.js.map +1 -1
  81. package/browser/metadata-builder/EntityMetadataValidator.js +1 -0
  82. package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
  83. package/browser/migration/MigrationExecutor.js +1 -1
  84. package/browser/migration/MigrationExecutor.js.map +1 -1
  85. package/browser/persistence/SubjectExecutor.js +2 -2
  86. package/browser/persistence/SubjectExecutor.js.map +1 -1
  87. package/browser/persistence/subject-builder/OneToManySubjectBuilder.js +3 -0
  88. package/browser/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
  89. package/browser/query-builder/DeleteQueryBuilder.d.ts +4 -2
  90. package/browser/query-builder/DeleteQueryBuilder.js +4 -2
  91. package/browser/query-builder/DeleteQueryBuilder.js.map +1 -1
  92. package/browser/query-builder/InsertQueryBuilder.d.ts +1 -1
  93. package/browser/query-builder/InsertQueryBuilder.js +1 -1
  94. package/browser/query-builder/InsertQueryBuilder.js.map +1 -1
  95. package/browser/query-builder/NotBrackets.d.ts +7 -0
  96. package/browser/query-builder/NotBrackets.js +16 -0
  97. package/browser/query-builder/NotBrackets.js.map +1 -0
  98. package/browser/query-builder/QueryBuilder.d.ts +3 -2
  99. package/browser/query-builder/QueryBuilder.js +2 -1
  100. package/browser/query-builder/QueryBuilder.js.map +1 -1
  101. package/browser/query-builder/RelationQueryBuilder.d.ts +1 -1
  102. package/browser/query-builder/RelationQueryBuilder.js +1 -1
  103. package/browser/query-builder/RelationQueryBuilder.js.map +1 -1
  104. package/browser/query-builder/ReturningResultsEntityUpdator.d.ts +4 -0
  105. package/browser/query-builder/ReturningResultsEntityUpdator.js +11 -2
  106. package/browser/query-builder/ReturningResultsEntityUpdator.js.map +1 -1
  107. package/browser/query-builder/SelectQueryBuilder.d.ts +1 -1
  108. package/browser/query-builder/SelectQueryBuilder.js +1 -1
  109. package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
  110. package/browser/query-builder/SoftDeleteQueryBuilder.d.ts +1 -1
  111. package/browser/query-builder/SoftDeleteQueryBuilder.js +2 -2
  112. package/browser/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
  113. package/browser/query-builder/UpdateQueryBuilder.d.ts +4 -2
  114. package/browser/query-builder/UpdateQueryBuilder.js +11 -6
  115. package/browser/query-builder/UpdateQueryBuilder.js.map +1 -1
  116. package/browser/query-builder/WhereExpressionBuilder.d.ts +3 -1
  117. package/browser/query-builder/WhereExpressionBuilder.js.map +1 -1
  118. package/browser/repository/AbstractRepository.d.ts +2 -2
  119. package/browser/repository/AbstractRepository.js +2 -2
  120. package/browser/repository/AbstractRepository.js.map +1 -1
  121. package/browser/repository/BaseEntity.d.ts +1 -1
  122. package/browser/repository/BaseEntity.js +1 -1
  123. package/browser/repository/BaseEntity.js.map +1 -1
  124. package/browser/repository/Repository.d.ts +1 -1
  125. package/browser/repository/Repository.js +1 -1
  126. package/browser/repository/Repository.js.map +1 -1
  127. package/browser/schema-builder/options/TableColumnOptions.d.ts +4 -0
  128. package/browser/schema-builder/options/TableColumnOptions.js.map +1 -1
  129. package/browser/schema-builder/options/TableUniqueOptions.d.ts +5 -0
  130. package/browser/schema-builder/options/TableUniqueOptions.js.map +1 -1
  131. package/browser/schema-builder/table/TableColumn.d.ts +4 -0
  132. package/browser/schema-builder/table/TableColumn.js +2 -0
  133. package/browser/schema-builder/table/TableColumn.js.map +1 -1
  134. package/browser/schema-builder/table/TableUnique.d.ts +5 -0
  135. package/browser/schema-builder/table/TableUnique.js +5 -2
  136. package/browser/schema-builder/table/TableUnique.js.map +1 -1
  137. package/browser/schema-builder/util/TableUtils.js +1 -0
  138. package/browser/schema-builder/util/TableUtils.js.map +1 -1
  139. package/browser/util/DirectoryExportedClassesLoader.d.ts +1 -1
  140. package/browser/util/DirectoryExportedClassesLoader.js +55 -31
  141. package/browser/util/DirectoryExportedClassesLoader.js.map +1 -1
  142. package/browser/util/ImportUtils.d.ts +1 -0
  143. package/browser/util/ImportUtils.js +90 -0
  144. package/browser/util/ImportUtils.js.map +1 -0
  145. package/cache/RedisQueryResultCache.js +39 -34
  146. package/cache/RedisQueryResultCache.js.map +1 -1
  147. package/commands/InitCommand.d.ts +9 -7
  148. package/commands/InitCommand.js +72 -43
  149. package/commands/InitCommand.js.map +1 -1
  150. package/commands/QueryCommand.d.ts +1 -1
  151. package/commands/QueryCommand.js +1 -1
  152. package/commands/QueryCommand.js.map +1 -1
  153. package/common/RelationType.d.ts +14 -0
  154. package/common/RelationType.js +4 -0
  155. package/common/RelationType.js.map +1 -0
  156. package/connection/Connection.d.ts +3 -3
  157. package/connection/Connection.js +46 -31
  158. package/connection/Connection.js.map +1 -1
  159. package/connection/ConnectionMetadataBuilder.d.ts +3 -3
  160. package/connection/ConnectionMetadataBuilder.js +53 -21
  161. package/connection/ConnectionMetadataBuilder.js.map +1 -1
  162. package/connection/ConnectionOptionsReader.js +32 -27
  163. package/connection/ConnectionOptionsReader.js.map +1 -1
  164. package/decorator/Unique.d.ts +5 -4
  165. package/decorator/Unique.js +7 -3
  166. package/decorator/Unique.js.map +1 -1
  167. package/decorator/columns/PrimaryGeneratedColumn.d.ts +2 -1
  168. package/decorator/columns/PrimaryGeneratedColumn.js.map +1 -1
  169. package/decorator/options/ColumnOptions.d.ts +4 -0
  170. package/decorator/options/ColumnOptions.js.map +1 -1
  171. package/decorator/options/PrimaryGeneratedColumnIdentityOptions.d.ts +22 -0
  172. package/decorator/options/PrimaryGeneratedColumnIdentityOptions.js +4 -0
  173. package/decorator/options/PrimaryGeneratedColumnIdentityOptions.js.map +1 -0
  174. package/decorator/options/RelationOptions.d.ts +1 -1
  175. package/decorator/options/RelationOptions.js.map +1 -1
  176. package/decorator/options/UniqueOptions.d.ts +10 -0
  177. package/decorator/options/UniqueOptions.js +4 -0
  178. package/decorator/options/UniqueOptions.js.map +1 -0
  179. package/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
  180. package/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
  181. package/driver/better-sqlite3/BetterSqlite3Driver.js +7 -5
  182. package/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
  183. package/driver/cockroachdb/CockroachQueryRunner.js +1 -1
  184. package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  185. package/driver/mysql/MysqlQueryRunner.js +1 -1
  186. package/driver/mysql/MysqlQueryRunner.js.map +1 -1
  187. package/driver/oracle/OracleQueryRunner.js +1 -1
  188. package/driver/oracle/OracleQueryRunner.js.map +1 -1
  189. package/driver/postgres/PostgresQueryRunner.js +14 -5
  190. package/driver/postgres/PostgresQueryRunner.js.map +1 -1
  191. package/driver/sap/SapQueryRunner.js +1 -1
  192. package/driver/sap/SapQueryRunner.js.map +1 -1
  193. package/driver/sqlite/SqliteDriver.js +11 -10
  194. package/driver/sqlite/SqliteDriver.js.map +1 -1
  195. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
  196. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  197. package/driver/sqlserver/SqlServerQueryRunner.js +1 -1
  198. package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  199. package/entity-manager/EntityManager.d.ts +2 -2
  200. package/entity-manager/EntityManager.js +1 -1
  201. package/entity-manager/EntityManager.js.map +1 -1
  202. package/entity-manager/MongoEntityManager.js +2 -1
  203. package/entity-manager/MongoEntityManager.js.map +1 -1
  204. package/entity-schema/EntitySchemaOptions.d.ts +6 -0
  205. package/entity-schema/EntitySchemaOptions.js.map +1 -1
  206. package/entity-schema/EntitySchemaRelationOptions.d.ts +1 -1
  207. package/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
  208. package/entity-schema/EntitySchemaTransformer.js +3 -1
  209. package/entity-schema/EntitySchemaTransformer.js.map +1 -1
  210. package/entity-schema/EntitySchemaUniqueOptions.d.ts +5 -0
  211. package/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
  212. package/find-options/operator/Like.d.ts +1 -1
  213. package/find-options/operator/Like.js +1 -1
  214. package/find-options/operator/Like.js.map +1 -1
  215. package/globals.js +33 -6
  216. package/globals.js.map +1 -1
  217. package/index.d.ts +10 -0
  218. package/index.js +12 -1
  219. package/index.js.map +1 -1
  220. package/index.mjs +352 -0
  221. package/metadata/ColumnMetadata.d.ts +4 -0
  222. package/metadata/ColumnMetadata.js +2 -0
  223. package/metadata/ColumnMetadata.js.map +1 -1
  224. package/metadata/RelationMetadata.d.ts +1 -1
  225. package/metadata/RelationMetadata.js.map +1 -1
  226. package/metadata/UniqueMetadata.d.ts +5 -0
  227. package/metadata/UniqueMetadata.js +1 -0
  228. package/metadata/UniqueMetadata.js.map +1 -1
  229. package/metadata-args/UniqueMetadataArgs.d.ts +5 -0
  230. package/metadata-args/UniqueMetadataArgs.js.map +1 -1
  231. package/metadata-builder/EntityMetadataValidator.js +1 -0
  232. package/metadata-builder/EntityMetadataValidator.js.map +1 -1
  233. package/migration/MigrationExecutor.js +1 -1
  234. package/migration/MigrationExecutor.js.map +1 -1
  235. package/package.json +1 -1
  236. package/persistence/SubjectExecutor.js +2 -2
  237. package/persistence/SubjectExecutor.js.map +1 -1
  238. package/persistence/subject-builder/OneToManySubjectBuilder.js +3 -0
  239. package/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
  240. package/query-builder/DeleteQueryBuilder.d.ts +4 -2
  241. package/query-builder/DeleteQueryBuilder.js +4 -2
  242. package/query-builder/DeleteQueryBuilder.js.map +1 -1
  243. package/query-builder/InsertQueryBuilder.d.ts +1 -1
  244. package/query-builder/InsertQueryBuilder.js +1 -1
  245. package/query-builder/InsertQueryBuilder.js.map +1 -1
  246. package/query-builder/NotBrackets.d.ts +7 -0
  247. package/query-builder/NotBrackets.js +19 -0
  248. package/query-builder/NotBrackets.js.map +1 -0
  249. package/query-builder/QueryBuilder.d.ts +3 -2
  250. package/query-builder/QueryBuilder.js +2 -1
  251. package/query-builder/QueryBuilder.js.map +1 -1
  252. package/query-builder/RelationQueryBuilder.d.ts +1 -1
  253. package/query-builder/RelationQueryBuilder.js +1 -1
  254. package/query-builder/RelationQueryBuilder.js.map +1 -1
  255. package/query-builder/ReturningResultsEntityUpdator.d.ts +4 -0
  256. package/query-builder/ReturningResultsEntityUpdator.js +11 -2
  257. package/query-builder/ReturningResultsEntityUpdator.js.map +1 -1
  258. package/query-builder/SelectQueryBuilder.d.ts +1 -1
  259. package/query-builder/SelectQueryBuilder.js +1 -1
  260. package/query-builder/SelectQueryBuilder.js.map +1 -1
  261. package/query-builder/SoftDeleteQueryBuilder.d.ts +1 -1
  262. package/query-builder/SoftDeleteQueryBuilder.js +2 -2
  263. package/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
  264. package/query-builder/UpdateQueryBuilder.d.ts +4 -2
  265. package/query-builder/UpdateQueryBuilder.js +11 -6
  266. package/query-builder/UpdateQueryBuilder.js.map +1 -1
  267. package/query-builder/WhereExpressionBuilder.d.ts +3 -1
  268. package/query-builder/WhereExpressionBuilder.js.map +1 -1
  269. package/repository/AbstractRepository.d.ts +2 -2
  270. package/repository/AbstractRepository.js +2 -2
  271. package/repository/AbstractRepository.js.map +1 -1
  272. package/repository/BaseEntity.d.ts +1 -1
  273. package/repository/BaseEntity.js +1 -1
  274. package/repository/BaseEntity.js.map +1 -1
  275. package/repository/Repository.d.ts +1 -1
  276. package/repository/Repository.js +1 -1
  277. package/repository/Repository.js.map +1 -1
  278. package/schema-builder/options/TableColumnOptions.d.ts +4 -0
  279. package/schema-builder/options/TableColumnOptions.js.map +1 -1
  280. package/schema-builder/options/TableUniqueOptions.d.ts +5 -0
  281. package/schema-builder/options/TableUniqueOptions.js.map +1 -1
  282. package/schema-builder/table/TableColumn.d.ts +4 -0
  283. package/schema-builder/table/TableColumn.js +2 -0
  284. package/schema-builder/table/TableColumn.js.map +1 -1
  285. package/schema-builder/table/TableUnique.d.ts +5 -0
  286. package/schema-builder/table/TableUnique.js +5 -2
  287. package/schema-builder/table/TableUnique.js.map +1 -1
  288. package/schema-builder/util/TableUtils.js +1 -0
  289. package/schema-builder/util/TableUtils.js.map +1 -1
  290. package/util/DirectoryExportedClassesLoader.d.ts +1 -1
  291. package/util/DirectoryExportedClassesLoader.js +54 -31
  292. package/util/DirectoryExportedClassesLoader.js.map +1 -1
  293. package/util/ImportUtils.d.ts +1 -0
  294. package/util/ImportUtils.js +94 -0
  295. package/util/ImportUtils.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/repository/BaseEntity.ts"],"names":[],"mappings":";;;;AACA,sCAAyC;AAczC,mDAAgD;AAIhD;;GAEG;AACH;IAAA;IAmYA,CAAC;IAvXG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,0BAAK,GAAL;QACI,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,yBAAI,GAAJ,UAAK,OAAqB;QACtB,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C,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;AAnYY,gCAAU","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":".."}
1
+ {"version":3,"sources":["../../src/repository/BaseEntity.ts"],"names":[],"mappings":";;;;AACA,sCAAyC;AAczC,mDAAgD;AAIhD;;GAEG;AACH;IAAA;IAmYA,CAAC;IAvXG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,0BAAK,GAAL;QACI,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,yBAAI,GAAJ,UAAK,OAAqB;QACtB,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACH,2BAAM,GAAN,UAAO,OAAuB;QAC1B,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;IAED;;OAEG;IACH,+BAAU,GAAV,UAAW,OAAqB;QAC5B,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAED;;OAEG;IACH,4BAAO,GAAP,UAAQ,OAAqB;QACzB,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,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jG,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;AAnYY,gCAAU","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":".."}
@@ -32,7 +32,7 @@ export declare class Repository<Entity extends ObjectLiteral> {
32
32
  */
33
33
  readonly queryRunner?: QueryRunner;
34
34
  /**
35
- * Creates a new query builder that can be used to build a sql query.
35
+ * Creates a new query builder that can be used to build a SQL query.
36
36
  */
37
37
  createQueryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity>;
38
38
  /**
@@ -12,7 +12,7 @@ var Repository = /** @class */ (function () {
12
12
  // Public Methods
13
13
  // -------------------------------------------------------------------------
14
14
  /**
15
- * Creates a new query builder that can be used to build a sql query.
15
+ * Creates a new query builder that can be used to build a SQL query.
16
16
  */
17
17
  Repository.prototype.createQueryBuilder = function (alias, queryRunner) {
18
18
  return this.manager.createQueryBuilder(this.metadata.target, alias || this.metadata.targetName, queryRunner || this.queryRunner);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/repository/Repository.ts"],"names":[],"mappings":";;;;AAkBA;;GAEG;AACH;IAAA;IAiaA,CAAC;IA5YG,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,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAmBD;;;OAGG;IACH,2BAAM,GAAN,UAAO,iCAA6E;QAChF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,IAAI,CAA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AE,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,CAjaA,AAiaC,IAAA;AAjaY,gCAAU","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":".."}
1
+ {"version":3,"sources":["../../src/repository/Repository.ts"],"names":[],"mappings":";;;;AAkBA;;GAEG;AACH;IAAA;IAiaA,CAAC;IA5YG,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,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAmBD;;;OAGG;IACH,2BAAM,GAAN,UAAO,iCAA6E;QAChF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,IAAI,CAAC,QAAQ,CAAC,MAAa,EAAE,iCAAwC,CAAC,CAAC;IAC3G,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL,UAAM,eAAuB;;QAAE,qBAAqC;aAAr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AY,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,CAjaA,AAiaC,IAAA;AAjaY,gCAAU","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":".."}
@@ -99,6 +99,10 @@ export interface TableColumnOptions {
99
99
  * Generated column type. Supports only in MySQL.
100
100
  */
101
101
  generatedType?: "VIRTUAL" | "STORED";
102
+ /**
103
+ * Identity column type. Supports only in Postgres 10+.
104
+ */
105
+ generatedIdentity?: "ALWAYS" | "BY DEFAULT";
102
106
  /**
103
107
  * Spatial Feature Type (Geometry, Point, Polygon, etc.)
104
108
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema-builder/options/TableColumnOptions.ts"],"names":[],"mappings":"","file":"TableColumnOptions.js","sourcesContent":["\n/**\n * Table's column options.\n */\nexport interface TableColumnOptions {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Column name.\n */\n name: string;\n\n /**\n * Column type.\n */\n type: string;\n\n /**\n * Column's default value.\n */\n default?: any;\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string;\n\n /**\n * Indicates if column is NULL, or is NOT NULL in the database.\n */\n isNullable?: boolean;\n\n /**\n * Indicates if column is auto-generated sequence.\n */\n isGenerated?: boolean;\n\n /**\n * Specifies generation strategy if this column will use auto increment.\n */\n generationStrategy?: \"uuid\"|\"increment\"|\"rowid\"|\"identity\";\n\n /**\n * Indicates if column is a primary key.\n */\n isPrimary?: boolean;\n\n /**\n * Indicates if column has unique value.\n */\n isUnique?: boolean;\n\n /**\n * Indicates if column stores array.\n */\n isArray?: boolean;\n\n /**\n * Column's comment.\n */\n comment?: string;\n\n /**\n * Column type's length. Used only on some column types.\n * For example type = \"string\" and length = \"100\" means that ORM will create a column with type varchar(100).\n */\n length?: string;\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n */\n width?: number;\n\n /**\n * Defines column character set.\n */\n charset?: string;\n\n /**\n * Defines column collation.\n */\n collation?: string;\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number|null;\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number;\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill?: boolean;\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean;\n\n /**\n * Array of possible enumerated values.\n */\n enum?: string[];\n\n /**\n * Exact name of enum\n */\n enumName?: string;\n\n /**\n * Generated column expression. Supports only in MySQL.\n */\n asExpression?: string;\n\n /**\n * Generated column type. Supports only in MySQL.\n */\n generatedType?: \"VIRTUAL\"|\"STORED\";\n\n /**\n * Spatial Feature Type (Geometry, Point, Polygon, etc.)\n */\n spatialFeatureType?: string;\n\n /**\n * SRID (Spatial Reference ID (EPSG code))\n */\n srid?: number;\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/schema-builder/options/TableColumnOptions.ts"],"names":[],"mappings":"","file":"TableColumnOptions.js","sourcesContent":["\n/**\n * Table's column options.\n */\nexport interface TableColumnOptions {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Column name.\n */\n name: string;\n\n /**\n * Column type.\n */\n type: string;\n\n /**\n * Column's default value.\n */\n default?: any;\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string;\n\n /**\n * Indicates if column is NULL, or is NOT NULL in the database.\n */\n isNullable?: boolean;\n\n /**\n * Indicates if column is auto-generated sequence.\n */\n isGenerated?: boolean;\n\n /**\n * Specifies generation strategy if this column will use auto increment.\n */\n generationStrategy?: \"uuid\"|\"increment\"|\"rowid\"|\"identity\";\n\n /**\n * Indicates if column is a primary key.\n */\n isPrimary?: boolean;\n\n /**\n * Indicates if column has unique value.\n */\n isUnique?: boolean;\n\n /**\n * Indicates if column stores array.\n */\n isArray?: boolean;\n\n /**\n * Column's comment.\n */\n comment?: string;\n\n /**\n * Column type's length. Used only on some column types.\n * For example type = \"string\" and length = \"100\" means that ORM will create a column with type varchar(100).\n */\n length?: string;\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n */\n width?: number;\n\n /**\n * Defines column character set.\n */\n charset?: string;\n\n /**\n * Defines column collation.\n */\n collation?: string;\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number|null;\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number;\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill?: boolean;\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean;\n\n /**\n * Array of possible enumerated values.\n */\n enum?: string[];\n\n /**\n * Exact name of enum\n */\n enumName?: string;\n\n /**\n * Generated column expression. Supports only in MySQL.\n */\n asExpression?: string;\n\n /**\n * Generated column type. Supports only in MySQL.\n */\n generatedType?: \"VIRTUAL\"|\"STORED\";\n\n /**\n * Identity column type. Supports only in Postgres 10+.\n */\n generatedIdentity?: \"ALWAYS\"|\"BY DEFAULT\";\n\n /**\n * Spatial Feature Type (Geometry, Point, Polygon, etc.)\n */\n spatialFeatureType?: string;\n\n /**\n * SRID (Spatial Reference ID (EPSG code))\n */\n srid?: number;\n}\n"],"sourceRoot":"../.."}
@@ -10,4 +10,9 @@ export interface TableUniqueOptions {
10
10
  * Columns that contains this constraint.
11
11
  */
12
12
  columnNames: string[];
13
+ /**
14
+ * Set this foreign key constraint as "DEFERRABLE" e.g. check constraints at start
15
+ * or at the end of a transaction
16
+ */
17
+ deferrable?: string;
13
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema-builder/options/TableUniqueOptions.ts"],"names":[],"mappings":"","file":"TableUniqueOptions.js","sourcesContent":["/**\n * Database's table unique constraint options.\n */\nexport interface TableUniqueOptions {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[];\n\n}"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/schema-builder/options/TableUniqueOptions.ts"],"names":[],"mappings":"","file":"TableUniqueOptions.js","sourcesContent":["/**\n * Database's table unique constraint options.\n */\nexport interface TableUniqueOptions {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[];\n\n /**\n * Set this foreign key constraint as \"DEFERRABLE\" e.g. check constraints at start\n * or at the end of a transaction\n */\n deferrable?: string;\n\n}"],"sourceRoot":"../.."}
@@ -101,6 +101,10 @@ export declare class TableColumn {
101
101
  * Generated column type. Supports only in MySQL.
102
102
  */
103
103
  generatedType?: "VIRTUAL" | "STORED";
104
+ /**
105
+ * Identity column type. Supports only in Postgres 10+.
106
+ */
107
+ generatedIdentity?: "ALWAYS" | "BY DEFAULT";
104
108
  /**
105
109
  * Spatial Feature Type (Geometry, Point, Polygon, etc.)
106
110
  */
@@ -59,6 +59,7 @@ var TableColumn = /** @class */ (function () {
59
59
  this.isNullable = options.isNullable || false;
60
60
  this.isGenerated = options.isGenerated || false;
61
61
  this.generationStrategy = options.generationStrategy;
62
+ this.generatedIdentity = options.generatedIdentity;
62
63
  this.isPrimary = options.isPrimary || false;
63
64
  this.isUnique = options.isUnique || false;
64
65
  this.isArray = options.isArray || false;
@@ -98,6 +99,7 @@ var TableColumn = /** @class */ (function () {
98
99
  isNullable: this.isNullable,
99
100
  isGenerated: this.isGenerated,
100
101
  generationStrategy: this.generationStrategy,
102
+ generatedIdentity: this.generatedIdentity,
101
103
  isPrimary: this.isPrimary,
102
104
  isUnique: this.isUnique,
103
105
  isArray: this.isArray,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema-builder/table/TableColumn.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH;IAyII,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAY,OAA4B;QAnHxC;;WAEG;QACH,eAAU,GAAY,KAAK,CAAC;QAE5B;;WAEG;QACH,gBAAW,GAAY,KAAK,CAAC;QAQ7B;;WAEG;QACH,cAAS,GAAY,KAAK,CAAC;QAE3B;;WAEG;QACH,aAAQ,GAAY,KAAK,CAAC;QAE1B;;WAEG;QACH,YAAO,GAAY,KAAK,CAAC;QAOzB;;;WAGG;QACH,WAAM,GAAW,EAAE,CAAC;QA8BpB;;;WAGG;QACH,aAAQ,GAAY,KAAK,CAAC;QAE1B;;WAEG;QACH,aAAQ,GAAY,KAAK,CAAC;QAqCtB,IAAI,OAAO,EAAE;YACT,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;YAC/B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;YACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;YACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YAC3B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;YAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,CA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B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,IAAI,EAAE,IAAI,CAAC,IAAI;SAClB,CAAC,CAAC;IACP,CAAC;IAEL,kBAAC;AAAD,CAhNA,AAgNC,IAAA;AAhNY,kCAAW","file":"TableColumn.js","sourcesContent":["import {TableColumnOptions} from \"../options/TableColumnOptions\";\n\n/**\n * Table's columns in the database represented in this class.\n */\nexport class TableColumn {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Column name.\n */\n name: string;\n\n /**\n * Column type.\n */\n type: string;\n\n /**\n * Column's default value.\n */\n default?: any;\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string;\n\n /**\n * Indicates if column is NULL, or is NOT NULL in the database.\n */\n isNullable: boolean = false;\n\n /**\n * Indicates if column is auto-generated sequence.\n */\n isGenerated: boolean = false;\n\n /**\n * Specifies generation strategy if this column will use auto increment.\n * `rowid` option supported only in CockroachDB.\n */\n generationStrategy?: \"uuid\"|\"increment\"|\"rowid\"|\"identity\";\n\n /**\n * Indicates if column is a primary key.\n */\n isPrimary: boolean = false;\n\n /**\n * Indicates if column has unique value.\n */\n isUnique: boolean = false;\n\n /**\n * Indicates if column stores array.\n */\n isArray: boolean = false;\n\n /**\n * Column's comment.\n */\n comment?: string;\n\n /**\n * Column type's length. Used only on some column types.\n * For example type = \"string\" and length = \"100\" means that ORM will create a column with type varchar(100).\n */\n length: string = \"\";\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n */\n width?: number;\n\n /**\n * Defines column character set.\n */\n charset?: string;\n\n /**\n * Defines column collation.\n */\n collation?: string;\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number|null;\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number;\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill: boolean = false;\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned: boolean = false;\n\n /**\n * Array of possible enumerated values.\n */\n enum?: string[];\n\n /**\n * Exact name of enum\n */\n enumName?: string;\n\n /**\n * Generated column expression. Supports only in MySQL.\n */\n asExpression?: string;\n\n /**\n * Generated column type. Supports only in MySQL.\n */\n generatedType?: \"VIRTUAL\"|\"STORED\";\n\n /**\n * Spatial Feature Type (Geometry, Point, Polygon, etc.)\n */\n spatialFeatureType?: string;\n\n /**\n * SRID (Spatial Reference ID (EPSG code))\n */\n srid?: number;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options?: TableColumnOptions) {\n if (options) {\n this.name = options.name;\n this.type = options.type || \"\";\n this.length = options.length || \"\";\n this.width = options.width;\n this.charset = options.charset;\n this.collation = options.collation;\n this.precision = options.precision;\n this.scale = options.scale;\n this.zerofill = options.zerofill || false;\n this.unsigned = this.zerofill ? true : (options.unsigned || false);\n this.default = options.default;\n this.onUpdate = options.onUpdate;\n this.isNullable = options.isNullable || false;\n this.isGenerated = options.isGenerated || false;\n this.generationStrategy = options.generationStrategy;\n this.isPrimary = options.isPrimary || false;\n this.isUnique = options.isUnique || false;\n this.isArray = options.isArray || false;\n this.comment = options.comment;\n this.enum = options.enum;\n this.enumName = options.enumName;\n this.asExpression = options.asExpression;\n this.generatedType = options.generatedType;\n this.spatialFeatureType = options.spatialFeatureType;\n this.srid = options.srid;\n }\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Clones this column to a new column with exact same properties as this column has.\n */\n clone(): TableColumn {\n return new TableColumn(<TableColumnOptions>{\n name: this.name,\n type: this.type,\n length: this.length,\n width: this.width,\n charset: this.charset,\n collation: this.collation,\n precision: this.precision,\n scale: this.scale,\n zerofill: this.zerofill,\n unsigned: this.unsigned,\n enum: this.enum,\n enumName: this.enumName,\n asExpression: this.asExpression,\n generatedType: this.generatedType,\n default: this.default,\n onUpdate: this.onUpdate,\n isNullable: this.isNullable,\n isGenerated: this.isGenerated,\n generationStrategy: this.generationStrategy,\n isPrimary: this.isPrimary,\n isUnique: this.isUnique,\n isArray: this.isArray,\n comment: this.comment,\n spatialFeatureType: this.spatialFeatureType,\n srid: this.srid\n });\n }\n\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/schema-builder/table/TableColumn.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH;IA8II,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAY,OAA4B;QAxHxC;;WAEG;QAC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AI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,IAAI,EAAE,IAAI,CAAC,IAAI;SAClB,CAAC,CAAC;IACP,CAAC;IAEL,kBAAC;AAAD,CAvNA,AAuNC,IAAA;AAvNY,kCAAW","file":"TableColumn.js","sourcesContent":["import {TableColumnOptions} from \"../options/TableColumnOptions\";\n\n/**\n * Table's columns in the database represented in this class.\n */\nexport class TableColumn {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Column name.\n */\n name: string;\n\n /**\n * Column type.\n */\n type: string;\n\n /**\n * Column's default value.\n */\n default?: any;\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string;\n\n /**\n * Indicates if column is NULL, or is NOT NULL in the database.\n */\n isNullable: boolean = false;\n\n /**\n * Indicates if column is auto-generated sequence.\n */\n isGenerated: boolean = false;\n\n /**\n * Specifies generation strategy if this column will use auto increment.\n * `rowid` option supported only in CockroachDB.\n */\n generationStrategy?: \"uuid\"|\"increment\"|\"rowid\"|\"identity\";\n\n /**\n * Indicates if column is a primary key.\n */\n isPrimary: boolean = false;\n\n /**\n * Indicates if column has unique value.\n */\n isUnique: boolean = false;\n\n /**\n * Indicates if column stores array.\n */\n isArray: boolean = false;\n\n /**\n * Column's comment.\n */\n comment?: string;\n\n /**\n * Column type's length. Used only on some column types.\n * For example type = \"string\" and length = \"100\" means that ORM will create a column with type varchar(100).\n */\n length: string = \"\";\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n */\n width?: number;\n\n /**\n * Defines column character set.\n */\n charset?: string;\n\n /**\n * Defines column collation.\n */\n collation?: string;\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number|null;\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number;\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill: boolean = false;\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned: boolean = false;\n\n /**\n * Array of possible enumerated values.\n */\n enum?: string[];\n\n /**\n * Exact name of enum\n */\n enumName?: string;\n\n /**\n * Generated column expression. Supports only in MySQL.\n */\n asExpression?: string;\n\n /**\n * Generated column type. Supports only in MySQL.\n */\n generatedType?: \"VIRTUAL\"|\"STORED\";\n\n /**\n * Identity column type. Supports only in Postgres 10+.\n */\n generatedIdentity?: \"ALWAYS\"|\"BY DEFAULT\";\n\n /**\n * Spatial Feature Type (Geometry, Point, Polygon, etc.)\n */\n spatialFeatureType?: string;\n\n /**\n * SRID (Spatial Reference ID (EPSG code))\n */\n srid?: number;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options?: TableColumnOptions) {\n if (options) {\n this.name = options.name;\n this.type = options.type || \"\";\n this.length = options.length || \"\";\n this.width = options.width;\n this.charset = options.charset;\n this.collation = options.collation;\n this.precision = options.precision;\n this.scale = options.scale;\n this.zerofill = options.zerofill || false;\n this.unsigned = this.zerofill ? true : (options.unsigned || false);\n this.default = options.default;\n this.onUpdate = options.onUpdate;\n this.isNullable = options.isNullable || false;\n this.isGenerated = options.isGenerated || false;\n this.generationStrategy = options.generationStrategy;\n this.generatedIdentity = options.generatedIdentity;\n this.isPrimary = options.isPrimary || false;\n this.isUnique = options.isUnique || false;\n this.isArray = options.isArray || false;\n this.comment = options.comment;\n this.enum = options.enum;\n this.enumName = options.enumName;\n this.asExpression = options.asExpression;\n this.generatedType = options.generatedType;\n this.spatialFeatureType = options.spatialFeatureType;\n this.srid = options.srid;\n }\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Clones this column to a new column with exact same properties as this column has.\n */\n clone(): TableColumn {\n return new TableColumn(<TableColumnOptions>{\n name: this.name,\n type: this.type,\n length: this.length,\n width: this.width,\n charset: this.charset,\n collation: this.collation,\n precision: this.precision,\n scale: this.scale,\n zerofill: this.zerofill,\n unsigned: this.unsigned,\n enum: this.enum,\n enumName: this.enumName,\n asExpression: this.asExpression,\n generatedType: this.generatedType,\n default: this.default,\n onUpdate: this.onUpdate,\n isNullable: this.isNullable,\n isGenerated: this.isGenerated,\n generationStrategy: this.generationStrategy,\n generatedIdentity: this.generatedIdentity,\n isPrimary: this.isPrimary,\n isUnique: this.isUnique,\n isArray: this.isArray,\n comment: this.comment,\n spatialFeatureType: this.spatialFeatureType,\n srid: this.srid\n });\n }\n\n}\n"],"sourceRoot":"../.."}
@@ -12,6 +12,11 @@ export declare class TableUnique {
12
12
  * Columns that contains this constraint.
13
13
  */
14
14
  columnNames: string[];
15
+ /**
16
+ * Set this foreign key constraint as "DEFERRABLE" e.g. check constraints at start
17
+ * or at the end of a transaction
18
+ */
19
+ deferrable?: string;
15
20
  constructor(options: TableUniqueOptions);
16
21
  /**
17
22
  * Creates a new copy of this constraint with exactly same properties.
@@ -16,6 +16,7 @@ var TableUnique = /** @class */ (function () {
16
16
  this.columnNames = [];
17
17
  this.name = options.name;
18
18
  this.columnNames = options.columnNames;
19
+ this.deferrable = options.deferrable;
19
20
  }
20
21
  // -------------------------------------------------------------------------
21
22
  // Public Methods
@@ -26,7 +27,8 @@ var TableUnique = /** @class */ (function () {
26
27
  TableUnique.prototype.clone = function () {
27
28
  return new TableUnique({
28
29
  name: this.name,
29
- columnNames: (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(this.columnNames), false)
30
+ columnNames: (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(this.columnNames), false),
31
+ deferrable: this.deferrable,
30
32
  });
31
33
  };
32
34
  // -------------------------------------------------------------------------
@@ -38,7 +40,8 @@ var TableUnique = /** @class */ (function () {
38
40
  TableUnique.create = function (uniqueMetadata) {
39
41
  return new TableUnique({
40
42
  name: uniqueMetadata.name,
41
- columnNames: uniqueMetadata.columns.map(function (column) { return column.databaseName; })
43
+ columnNames: uniqueMetadata.columns.map(function (column) { return column.databaseName; }),
44
+ deferrable: uniqueMetadata.deferrable,
42
45
  });
43
46
  };
44
47
  return TableUnique;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema-builder/table/TableUnique.ts"],"names":[],"mappings":";;;;AAGA;;GAEG;AACH;IAgBI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAY,OAA2B;QATvC;;WAEG;QACH,gBAAW,GAAa,EAAE,CAAC;QAOvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAC3C,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,2BAAK,GAAL;QACI,OAAO,IAAI,WAAW,CAAqB;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,qDAAM,IAAI,CAAC,WAAW,SAAC;SACrC,CAAC,CAAC;IACP,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACI,kBAAM,GAAb,UAAc,cAA8B;QACxC,OAAO,IAAI,WAAW,CAAqB;YACvC,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,WAAW,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,YAAY,EAAnB,CAAmB,CAAC;SACzE,CAAC,CAAC;IACP,CAAC;IAEL,kBAAC;AAAD,CArDA,AAqDC,IAAA;AArDY,kCAAW","file":"TableUnique.js","sourcesContent":["import {TableUniqueOptions} from \"../options/TableUniqueOptions\";\nimport {UniqueMetadata} from \"../../metadata/UniqueMetadata\";\n\n/**\n * Database's table unique constraint stored in this class.\n */\nexport class TableUnique {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[] = [];\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options: TableUniqueOptions) {\n this.name = options.name;\n this.columnNames = options.columnNames;\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new copy of this constraint with exactly same properties.\n */\n clone(): TableUnique {\n return new TableUnique(<TableUniqueOptions>{\n name: this.name,\n columnNames: [...this.columnNames]\n });\n }\n\n // -------------------------------------------------------------------------\n // Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates unique from the unique metadata object.\n */\n static create(uniqueMetadata: UniqueMetadata): TableUnique {\n return new TableUnique(<TableUniqueOptions>{\n name: uniqueMetadata.name,\n columnNames: uniqueMetadata.columns.map(column => column.databaseName)\n });\n }\n\n}"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/schema-builder/table/TableUnique.ts"],"names":[],"mappings":";;;;AAGA;;GAEG;AACH;IAsBI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAY,OAA2B;QAfvC;;WAEG;QACH,gBAAW,GAAa,EAAE,CAAC;QAavB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACzC,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,2BAAK,GAAL;QACI,OAAO,IAAI,WAAW,CAAqB;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,qDAAM,IAAI,CAAC,WAAW,SAAC;YAClC,UAAU,EAAE,IAAI,CAAC,UAAU;SAC9B,CAAC,CAAC;IACP,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACI,kBAAM,GAAb,UAAc,cAA8B;QACxC,OAAO,IAAI,WAAW,CAAqB;YACvC,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,WAAW,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,YAAY,EAAnB,CAAmB,CAAC;YACtE,UAAU,EAAE,cAAc,CAAC,UAAU;SACxC,CAAC,CAAC;IACP,CAAC;IAEL,kBAAC;AAAD,CA9DA,AA8DC,IAAA;AA9DY,kCAAW","file":"TableUnique.js","sourcesContent":["import {TableUniqueOptions} from \"../options/TableUniqueOptions\";\nimport {UniqueMetadata} from \"../../metadata/UniqueMetadata\";\n\n/**\n * Database's table unique constraint stored in this class.\n */\nexport class TableUnique {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[] = [];\n\n /**\n * Set this foreign key constraint as \"DEFERRABLE\" e.g. check constraints at start\n * or at the end of a transaction\n */\n deferrable?: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options: TableUniqueOptions) {\n this.name = options.name;\n this.columnNames = options.columnNames;\n this.deferrable = options.deferrable;\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new copy of this constraint with exactly same properties.\n */\n clone(): TableUnique {\n return new TableUnique(<TableUniqueOptions>{\n name: this.name,\n columnNames: [...this.columnNames],\n deferrable: this.deferrable,\n });\n }\n\n // -------------------------------------------------------------------------\n // Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates unique from the unique metadata object.\n */\n static create(uniqueMetadata: UniqueMetadata): TableUnique {\n return new TableUnique(<TableUniqueOptions>{\n name: uniqueMetadata.name,\n columnNames: uniqueMetadata.columns.map(column => column.databaseName),\n deferrable: uniqueMetadata.deferrable,\n });\n }\n\n}"],"sourceRoot":"../.."}
@@ -22,6 +22,7 @@ var TableUtils = /** @class */ (function () {
22
22
  comment: columnMetadata.comment,
23
23
  isGenerated: columnMetadata.isGenerated,
24
24
  generationStrategy: columnMetadata.generationStrategy,
25
+ generatedIdentity: columnMetadata.generatedIdentity,
25
26
  isNullable: columnMetadata.isNullable,
26
27
  type: driver.normalizeType(columnMetadata),
27
28
  isPrimary: columnMetadata.isPrimary,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema-builder/util/TableUtils.ts"],"names":[],"mappings":";;;AAIA;IAAA;IAgCA,CAAC;IA9BU,mCAAwB,GAA/B,UAAgC,cAA8B,EAAE,MAAc;QAC1E,OAAO;YACH,IAAI,EAAE,cAAc,CAAC,YAAY;YACjC,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC,cAAc,CAAC;YAC9C,KAAK,EAAE,cAAc,CAAC,KAAK;YAC3B,OAAO,EAAE,cAAc,CAAC,OAAO;YAC/B,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,KAAK,EAAE,cAAc,CAAC,KAAK;YAC3B,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,YAAY,EAAE,cAAc,CAAC,YAAY;YACzC,aAAa,EAAE,cAAc,CAAC,aAAa;YAC3C,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC,cAAc,CAAC;YAChD,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,OAAO,EAAE,cAAc,CAAC,OAAO;YAC/B,WAAW,EAAE,cAAc,CAAC,WAAW;YACvC,kBAAkB,EAAE,cAAc,CAAC,kBAAkB;YACrD,UAAU,EAAE,cAAc,CAAC,UAAU;YACrC,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC;YAC1C,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,QAAQ,EAAE,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC;YAClD,OAAO,EAAE,cAAc,CAAC,OAAO,IAAI,KAAK;YACxC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,GAAG,EAAE,EAAR,CAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI;YAC1F,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,kBAAkB,EAAE,cAAc,CAAC,kBAAkB;YACrD,IAAI,EAAE,cAAc,CAAC,IAAI;SAC5B,CAAC;IACN,CAAC;IAEL,iBAAC;AAAD,CAhCA,AAgCC,IAAA;AAhCY,gCAAU","file":"TableUtils.js","sourcesContent":["import {TableColumnOptions} from \"../options/TableColumnOptions\";\nimport {ColumnMetadata} from \"../../metadata/ColumnMetadata\";\nimport {Driver} from \"../../driver/Driver\";\n\nexport class TableUtils {\n\n static createTableColumnOptions(columnMetadata: ColumnMetadata, driver: Driver): TableColumnOptions {\n return {\n name: columnMetadata.databaseName,\n length: driver.getColumnLength(columnMetadata),\n width: columnMetadata.width,\n charset: columnMetadata.charset,\n collation: columnMetadata.collation,\n precision: columnMetadata.precision,\n scale: columnMetadata.scale,\n zerofill: columnMetadata.zerofill,\n unsigned: columnMetadata.unsigned,\n asExpression: columnMetadata.asExpression,\n generatedType: columnMetadata.generatedType,\n default: driver.normalizeDefault(columnMetadata),\n onUpdate: columnMetadata.onUpdate,\n comment: columnMetadata.comment,\n isGenerated: columnMetadata.isGenerated,\n generationStrategy: columnMetadata.generationStrategy,\n isNullable: columnMetadata.isNullable,\n type: driver.normalizeType(columnMetadata),\n isPrimary: columnMetadata.isPrimary,\n isUnique: driver.normalizeIsUnique(columnMetadata),\n isArray: columnMetadata.isArray || false,\n enum: columnMetadata.enum ? columnMetadata.enum.map(val => val + \"\") : columnMetadata.enum,\n enumName: columnMetadata.enumName,\n spatialFeatureType: columnMetadata.spatialFeatureType,\n srid: columnMetadata.srid\n };\n }\n\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/schema-builder/util/TableUtils.ts"],"names":[],"mappings":";;;AAIA;IAAA;IAiCA,CAAC;IA/BU,mCAAwB,GAA/B,UAAgC,cAA8B,EAAE,MAAc;QAC1E,OAAO;YACH,IAAI,EAAE,cAAc,CAAC,YAAY;YACjC,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC,cAAc,CAAC;YAC9C,KAAK,EAAE,cAAc,CAAC,KAAK;YAC3B,OAAO,EAAE,cAAc,CAAC,OAAO;YAC/B,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,KAAK,EAAE,cAAc,CAAC,KAAK;YAC3B,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,YAAY,EAAE,cAAc,CAAC,YAAY;YACzC,aAAa,EAAE,cAAc,CAAC,aAAa;YAC3C,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC,cAAc,CAAC;YAChD,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,OAAO,EAAE,cAAc,CAAC,OAAO;YAC/B,WAAW,EAAE,cAAc,CAAC,WAAW;YACvC,kBAAkB,EAAE,cAAc,CAAC,kBAAkB;YACrD,iBAAiB,EAAE,cAAc,CAAC,iBAAiB;YACnD,UAAU,EAAE,cAAc,CAAC,UAAU;YACrC,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC;YAC1C,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,QAAQ,EAAE,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC;YAClD,OAAO,EAAE,cAAc,CAAC,OAAO,IAAI,KAAK;YACxC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,GAAG,EAAE,EAAR,CAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI;YAC1F,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,kBAAkB,EAAE,cAAc,CAAC,kBAAkB;YACrD,IAAI,EAAE,cAAc,CAAC,IAAI;SAC5B,CAAC;IACN,CAAC;IAEL,iBAAC;AAAD,CAjCA,AAiCC,IAAA;AAjCY,gCAAU","file":"TableUtils.js","sourcesContent":["import {TableColumnOptions} from \"../options/TableColumnOptions\";\nimport {ColumnMetadata} from \"../../metadata/ColumnMetadata\";\nimport {Driver} from \"../../driver/Driver\";\n\nexport class TableUtils {\n\n static createTableColumnOptions(columnMetadata: ColumnMetadata, driver: Driver): TableColumnOptions {\n return {\n name: columnMetadata.databaseName,\n length: driver.getColumnLength(columnMetadata),\n width: columnMetadata.width,\n charset: columnMetadata.charset,\n collation: columnMetadata.collation,\n precision: columnMetadata.precision,\n scale: columnMetadata.scale,\n zerofill: columnMetadata.zerofill,\n unsigned: columnMetadata.unsigned,\n asExpression: columnMetadata.asExpression,\n generatedType: columnMetadata.generatedType,\n default: driver.normalizeDefault(columnMetadata),\n onUpdate: columnMetadata.onUpdate,\n comment: columnMetadata.comment,\n isGenerated: columnMetadata.isGenerated,\n generationStrategy: columnMetadata.generationStrategy,\n generatedIdentity: columnMetadata.generatedIdentity,\n isNullable: columnMetadata.isNullable,\n type: driver.normalizeType(columnMetadata),\n isPrimary: columnMetadata.isPrimary,\n isUnique: driver.normalizeIsUnique(columnMetadata),\n isArray: columnMetadata.isArray || false,\n enum: columnMetadata.enum ? columnMetadata.enum.map(val => val + \"\") : columnMetadata.enum,\n enumName: columnMetadata.enumName,\n spatialFeatureType: columnMetadata.spatialFeatureType,\n srid: columnMetadata.srid\n };\n }\n\n}\n"],"sourceRoot":"../.."}
@@ -2,7 +2,7 @@ import { Logger } from "../logger/Logger";
2
2
  /**
3
3
  * Loads all exported classes from the given directory.
4
4
  */
5
- export declare function importClassesFromDirectories(logger: Logger, directories: string[], formats?: string[]): Function[];
5
+ export declare function importClassesFromDirectories(logger: Logger, directories: string[], formats?: string[]): Promise<Function[]>;
6
6
  /**
7
7
  * Loads all json files from the given directory.
8
8
  */
@@ -5,42 +5,65 @@ var tslib_1 = require("tslib");
5
5
  var glob_1 = (0, tslib_1.__importDefault)(require("glob"));
6
6
  var PlatformTools_1 = require("../platform/PlatformTools");
7
7
  var EntitySchema_1 = require("../entity-schema/EntitySchema");
8
+ var ImportUtils_1 = require("./ImportUtils");
8
9
  /**
9
10
  * Loads all exported classes from the given directory.
10
11
  */
11
12
  function importClassesFromDirectories(logger, directories, formats) {
12
- if (formats === void 0) { formats = [".js", ".cjs", ".ts"]; }
13
- var logLevel = "info";
14
- var classesNotFoundMessage = "No classes were found using the provided glob pattern: ";
15
- var classesFoundMessage = "All classes found using provided glob pattern";
16
- function loadFileClasses(exported, allLoaded) {
17
- if (typeof exported === "function" || exported instanceof EntitySchema_1.EntitySchema) {
18
- allLoaded.push(exported);
13
+ if (formats === void 0) { formats = [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]; }
14
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
15
+ function loadFileClasses(exported, allLoaded) {
16
+ if (typeof exported === "function" || exported instanceof EntitySchema_1.EntitySchema) {
17
+ allLoaded.push(exported);
18
+ }
19
+ else if (Array.isArray(exported)) {
20
+ exported.forEach(function (i) { return loadFileClasses(i, allLoaded); });
21
+ }
22
+ else if (typeof exported === "object" && exported !== null) {
23
+ Object.keys(exported).forEach(function (key) { return loadFileClasses(exported[key], allLoaded); });
24
+ }
25
+ return allLoaded;
19
26
  }
20
- else if (Array.isArray(exported)) {
21
- exported.forEach(function (i) { return loadFileClasses(i, allLoaded); });
22
- }
23
- else if (typeof exported === "object" && exported !== null) {
24
- Object.keys(exported).forEach(function (key) { return loadFileClasses(exported[key], allLoaded); });
25
- }
26
- return allLoaded;
27
- }
28
- var allFiles = directories.reduce(function (allDirs, dir) {
29
- return allDirs.concat(glob_1.default.sync(PlatformTools_1.PlatformTools.pathNormalize(dir)));
30
- }, []);
31
- if (directories.length > 0 && allFiles.length === 0) {
32
- logger.log(logLevel, classesNotFoundMessage + " \"" + directories + "\"");
33
- }
34
- else if (allFiles.length > 0) {
35
- logger.log(logLevel, classesFoundMessage + " \"" + directories + "\" : \"" + allFiles + "\"");
36
- }
37
- var dirs = allFiles
38
- .filter(function (file) {
39
- var dtsExtension = file.substring(file.length - 5, file.length);
40
- return formats.indexOf(PlatformTools_1.PlatformTools.pathExtname(file)) !== -1 && dtsExtension !== ".d.ts";
41
- })
42
- .map(function (file) { return require(PlatformTools_1.PlatformTools.pathResolve(file)); });
43
- return loadFileClasses(dirs, []);
27
+ var logLevel, classesNotFoundMessage, classesFoundMessage, allFiles, dirPromises, dirs;
28
+ var _this = this;
29
+ return (0, tslib_1.__generator)(this, function (_a) {
30
+ switch (_a.label) {
31
+ case 0:
32
+ logLevel = "info";
33
+ classesNotFoundMessage = "No classes were found using the provided glob pattern: ";
34
+ classesFoundMessage = "All classes found using provided glob pattern";
35
+ allFiles = directories.reduce(function (allDirs, dir) {
36
+ return allDirs.concat(glob_1.default.sync(PlatformTools_1.PlatformTools.pathNormalize(dir)));
37
+ }, []);
38
+ if (directories.length > 0 && allFiles.length === 0) {
39
+ logger.log(logLevel, classesNotFoundMessage + " \"" + directories + "\"");
40
+ }
41
+ else if (allFiles.length > 0) {
42
+ logger.log(logLevel, classesFoundMessage + " \"" + directories + "\" : \"" + allFiles + "\"");
43
+ }
44
+ dirPromises = allFiles
45
+ .filter(function (file) {
46
+ var dtsExtension = file.substring(file.length - 5, file.length);
47
+ return formats.indexOf(PlatformTools_1.PlatformTools.pathExtname(file)) !== -1 && dtsExtension !== ".d.ts";
48
+ })
49
+ .map(function (file) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
50
+ var _a, importOrRequireResult;
51
+ return (0, tslib_1.__generator)(this, function (_b) {
52
+ switch (_b.label) {
53
+ case 0: return [4 /*yield*/, (0, ImportUtils_1.importOrRequireFile)(PlatformTools_1.PlatformTools.pathResolve(file))];
54
+ case 1:
55
+ _a = tslib_1.__read.apply(void 0, [_b.sent(), 1]), importOrRequireResult = _a[0];
56
+ return [2 /*return*/, importOrRequireResult];
57
+ }
58
+ });
59
+ }); });
60
+ return [4 /*yield*/, Promise.all(dirPromises)];
61
+ case 1:
62
+ dirs = _a.sent();
63
+ return [2 /*return*/, loadFileClasses(dirs, [])];
64
+ }
65
+ });
66
+ });
44
67
  }
45
68
  exports.importClassesFromDirectories = importClassesFromDirectories;
46
69
  /**