typeorm 0.3.18-dev.a909d5b → 0.3.18-dev.aa8d24c

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 (166) hide show
  1. package/README.md +23 -23
  2. package/browser/driver/DriverUtils.js +2 -5
  3. package/browser/driver/DriverUtils.js.map +1 -1
  4. package/browser/driver/mongodb/MongoQueryRunner.d.ts +3 -3
  5. package/browser/driver/mongodb/MongoQueryRunner.js.map +1 -1
  6. package/browser/driver/mongodb/typings.d.ts +3 -3
  7. package/browser/driver/mongodb/typings.js.map +1 -1
  8. package/browser/driver/oracle/OracleQueryRunner.js +34 -2
  9. package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
  10. package/browser/driver/postgres/PostgresQueryRunner.js +20 -12
  11. package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
  12. package/browser/driver/sap/SapDriver.d.ts +8 -0
  13. package/browser/driver/sap/SapDriver.js +14 -3
  14. package/browser/driver/sap/SapDriver.js.map +1 -1
  15. package/browser/driver/sap/SapQueryRunner.d.ts +5 -14
  16. package/browser/driver/sap/SapQueryRunner.js +53 -55
  17. package/browser/driver/sap/SapQueryRunner.js.map +1 -1
  18. package/browser/driver/sqlserver/SqlServerConnectionCredentialsOptions.d.ts +2 -1
  19. package/browser/driver/sqlserver/SqlServerConnectionCredentialsOptions.js.map +1 -1
  20. package/browser/driver/sqlserver/SqlServerConnectionOptions.d.ts +5 -0
  21. package/browser/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  22. package/browser/driver/sqlserver/SqlServerQueryRunner.js +13 -0
  23. package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  24. package/browser/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.d.ts +12 -0
  25. package/browser/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.js +3 -0
  26. package/browser/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.js.map +1 -0
  27. package/browser/entity-manager/EntityManager.js +5 -1
  28. package/browser/entity-manager/EntityManager.js.map +1 -1
  29. package/browser/entity-manager/MongoEntityManager.d.ts +8 -4
  30. package/browser/entity-manager/MongoEntityManager.js +7 -0
  31. package/browser/entity-manager/MongoEntityManager.js.map +1 -1
  32. package/browser/entity-schema/EntitySchemaOptions.d.ts +4 -0
  33. package/browser/entity-schema/EntitySchemaOptions.js.map +1 -1
  34. package/browser/entity-schema/EntitySchemaTransformer.js +7 -0
  35. package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
  36. package/browser/error/QueryFailedError.d.ts +3 -3
  37. package/browser/error/QueryFailedError.js.map +1 -1
  38. package/browser/find-options/FindOptionsUtils.js +1 -1
  39. package/browser/find-options/FindOptionsUtils.js.map +1 -1
  40. package/browser/find-options/FindOptionsWhere.d.ts +1 -1
  41. package/browser/find-options/FindOptionsWhere.js.map +1 -1
  42. package/browser/index.d.ts +1 -0
  43. package/browser/index.js +1 -0
  44. package/browser/index.js.map +1 -1
  45. package/browser/metadata-builder/EntityMetadataBuilder.js +13 -0
  46. package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  47. package/browser/naming-strategy/DefaultNamingStrategy.d.ts +0 -1
  48. package/browser/naming-strategy/DefaultNamingStrategy.js +0 -3
  49. package/browser/naming-strategy/DefaultNamingStrategy.js.map +1 -1
  50. package/browser/naming-strategy/NamingStrategyInterface.d.ts +0 -4
  51. package/browser/naming-strategy/NamingStrategyInterface.js.map +1 -1
  52. package/browser/persistence/Subject.js +2 -1
  53. package/browser/persistence/Subject.js.map +1 -1
  54. package/browser/persistence/SubjectExecutor.js +1 -1
  55. package/browser/persistence/SubjectExecutor.js.map +1 -1
  56. package/browser/persistence/subject-builder/ManyToManySubjectBuilder.js +6 -2
  57. package/browser/persistence/subject-builder/ManyToManySubjectBuilder.js.map +1 -1
  58. package/browser/platform/PlatformTools.js +2 -0
  59. package/browser/platform/PlatformTools.js.map +1 -1
  60. package/browser/query-builder/QueryBuilder.js +1 -1
  61. package/browser/query-builder/QueryBuilder.js.map +1 -1
  62. package/browser/query-builder/SelectQueryBuilder.js +4 -1
  63. package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
  64. package/browser/repository/MongoRepository.d.ts +8 -4
  65. package/browser/repository/MongoRepository.js +6 -0
  66. package/browser/repository/MongoRepository.js.map +1 -1
  67. package/browser/repository/Repository.d.ts +1 -1
  68. package/browser/repository/Repository.js +9 -5
  69. package/browser/repository/Repository.js.map +1 -1
  70. package/browser/subscriber/Broadcaster.d.ts +1 -1
  71. package/browser/subscriber/Broadcaster.js +2 -1
  72. package/browser/subscriber/Broadcaster.js.map +1 -1
  73. package/browser/subscriber/event/InsertEvent.d.ts +5 -0
  74. package/browser/subscriber/event/InsertEvent.js.map +1 -1
  75. package/commands/CommandUtils.js +6 -1
  76. package/commands/CommandUtils.js.map +1 -1
  77. package/commands/EntityCreateCommand.d.ts +3 -0
  78. package/commands/EntityCreateCommand.js +7 -0
  79. package/commands/EntityCreateCommand.js.map +1 -1
  80. package/commands/InitCommand.js +1 -1
  81. package/commands/InitCommand.js.map +1 -1
  82. package/commands/MigrationCreateCommand.d.ts +5 -1
  83. package/commands/MigrationCreateCommand.js +6 -1
  84. package/commands/MigrationCreateCommand.js.map +1 -1
  85. package/commands/MigrationGenerateCommand.d.ts +5 -1
  86. package/commands/MigrationGenerateCommand.js +8 -1
  87. package/commands/MigrationGenerateCommand.js.map +1 -1
  88. package/commands/SubscriberCreateCommand.d.ts +3 -0
  89. package/commands/SubscriberCreateCommand.js +7 -0
  90. package/commands/SubscriberCreateCommand.js.map +1 -1
  91. package/driver/DriverUtils.js +2 -5
  92. package/driver/DriverUtils.js.map +1 -1
  93. package/driver/mongodb/MongoQueryRunner.d.ts +3 -3
  94. package/driver/mongodb/MongoQueryRunner.js.map +1 -1
  95. package/driver/mongodb/typings.d.ts +3 -3
  96. package/driver/mongodb/typings.js.map +1 -1
  97. package/driver/oracle/OracleQueryRunner.js +34 -2
  98. package/driver/oracle/OracleQueryRunner.js.map +1 -1
  99. package/driver/postgres/PostgresQueryRunner.js +20 -12
  100. package/driver/postgres/PostgresQueryRunner.js.map +1 -1
  101. package/driver/sap/SapDriver.d.ts +8 -0
  102. package/driver/sap/SapDriver.js +15 -4
  103. package/driver/sap/SapDriver.js.map +1 -1
  104. package/driver/sap/SapQueryRunner.d.ts +5 -14
  105. package/driver/sap/SapQueryRunner.js +53 -55
  106. package/driver/sap/SapQueryRunner.js.map +1 -1
  107. package/driver/sqlserver/SqlServerConnectionCredentialsOptions.d.ts +2 -1
  108. package/driver/sqlserver/SqlServerConnectionCredentialsOptions.js.map +1 -1
  109. package/driver/sqlserver/SqlServerConnectionOptions.d.ts +5 -0
  110. package/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  111. package/driver/sqlserver/SqlServerQueryRunner.js +13 -0
  112. package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  113. package/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.d.ts +12 -0
  114. package/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.js +4 -0
  115. package/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.js.map +1 -0
  116. package/entity-manager/EntityManager.js +5 -1
  117. package/entity-manager/EntityManager.js.map +1 -1
  118. package/entity-manager/MongoEntityManager.d.ts +8 -4
  119. package/entity-manager/MongoEntityManager.js +7 -0
  120. package/entity-manager/MongoEntityManager.js.map +1 -1
  121. package/entity-schema/EntitySchemaOptions.d.ts +4 -0
  122. package/entity-schema/EntitySchemaOptions.js.map +1 -1
  123. package/entity-schema/EntitySchemaTransformer.js +7 -0
  124. package/entity-schema/EntitySchemaTransformer.js.map +1 -1
  125. package/error/QueryFailedError.d.ts +3 -3
  126. package/error/QueryFailedError.js.map +1 -1
  127. package/find-options/FindOptionsUtils.js +1 -1
  128. package/find-options/FindOptionsUtils.js.map +1 -1
  129. package/find-options/FindOptionsWhere.d.ts +1 -1
  130. package/find-options/FindOptionsWhere.js.map +1 -1
  131. package/index.d.ts +1 -0
  132. package/index.js +1 -0
  133. package/index.js.map +1 -1
  134. package/index.mjs +2 -0
  135. package/metadata-builder/EntityMetadataBuilder.js +13 -0
  136. package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  137. package/naming-strategy/DefaultNamingStrategy.d.ts +0 -1
  138. package/naming-strategy/DefaultNamingStrategy.js +0 -3
  139. package/naming-strategy/DefaultNamingStrategy.js.map +1 -1
  140. package/naming-strategy/NamingStrategyInterface.d.ts +0 -4
  141. package/naming-strategy/NamingStrategyInterface.js.map +1 -1
  142. package/package.json +1 -1
  143. package/persistence/Subject.js +2 -1
  144. package/persistence/Subject.js.map +1 -1
  145. package/persistence/SubjectExecutor.js +1 -1
  146. package/persistence/SubjectExecutor.js.map +1 -1
  147. package/persistence/subject-builder/ManyToManySubjectBuilder.js +6 -2
  148. package/persistence/subject-builder/ManyToManySubjectBuilder.js.map +1 -1
  149. package/platform/PlatformTools.js +2 -0
  150. package/platform/PlatformTools.js.map +1 -1
  151. package/query-builder/QueryBuilder.js +1 -1
  152. package/query-builder/QueryBuilder.js.map +1 -1
  153. package/query-builder/SelectQueryBuilder.js +4 -1
  154. package/query-builder/SelectQueryBuilder.js.map +1 -1
  155. package/repository/MongoRepository.d.ts +8 -4
  156. package/repository/MongoRepository.js +6 -0
  157. package/repository/MongoRepository.js.map +1 -1
  158. package/repository/Repository.d.ts +1 -1
  159. package/repository/Repository.js +9 -5
  160. package/repository/Repository.js.map +1 -1
  161. package/subscriber/Broadcaster.d.ts +1 -1
  162. package/subscriber/Broadcaster.js +2 -1
  163. package/subscriber/Broadcaster.js.map +1 -1
  164. package/subscriber/event/InsertEvent.d.ts +5 -0
  165. package/subscriber/event/InsertEvent.js.map +1 -1
  166. package/typeorm-model-shim.js +61 -53
@@ -17,6 +17,11 @@ class MigrationCreateCommand {
17
17
  }
18
18
  builder(args) {
19
19
  return args
20
+ .positional("path", {
21
+ type: "string",
22
+ describe: "Path of the migration file",
23
+ demandOption: true,
24
+ })
20
25
  .option("o", {
21
26
  alias: "outputJs",
22
27
  type: "boolean",
@@ -56,7 +61,7 @@ class MigrationCreateCommand {
56
61
  * Gets contents of the migration file.
57
62
  */
58
63
  static getTemplate(name, timestamp) {
59
- return `import { MigrationInterface, QueryRunner } from "typeorm"
64
+ return `import { MigrationInterface, QueryRunner } from "typeorm";
60
65
 
61
66
  export class ${(0, StringUtils_1.camelCase)(name, true)}${timestamp} implements MigrationInterface {
62
67
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/MigrationCreateCommand.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,qDAA+C;AAE/C,0DAAyB;AACzB,6DAAyD;AACzD,wDAAuB;AAEvB;;GAEG;AACH,MAAa,sBAAsB;IAAnC;QACI,YAAO,GAAG,yBAAyB,CAAA;QACnC,aAAQ,GAAG,+BAA+B,CAAA;IAgG9C,CAAC;IA9FG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EACJ,+DAA+D;SACtE,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,yCAAyC;SACtD,CAAC,CAAA;IACV,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAqB;QAC/B,IAAI;YACA,MAAM,SAAS,GAAG,2BAAY,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC3D,MAAM,SAAS,GAAI,IAAI,CAAC,IAAe,CAAC,UAAU,CAAC,GAAG,CAAC;gBACnD,CAAC,CAAE,IAAI,CAAC,IAAe;gBACvB,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,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,GAAG,SAAS;;;;;;;;;CASzD,CAAA;IACG,CAAC;CACJ;AAlGD,wDAkGC","file":"MigrationCreateCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\"\nimport { camelCase } from \"../util/StringUtils\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport path from \"path\"\n\n/**\n * Creates a new migration file.\n */\nexport class MigrationCreateCommand implements yargs.CommandModule {\n command = \"migration:create <path>\"\n describe = \"Creates a new migration file.\"\n\n builder(args: yargs.Argv) {\n return args\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments) {\n try {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const inputPath = (args.path as string).startsWith(\"/\")\n ? (args.path as string)\n : path.resolve(process.cwd(), args.path as string)\n const filename = path.basename(inputPath)\n const fullPath =\n path.dirname(inputPath) + \"/\" + timestamp + \"-\" + filename\n\n const fileContent = args.outputJs\n ? MigrationCreateCommand.getJavascriptTemplate(\n filename,\n timestamp,\n )\n : MigrationCreateCommand.getTemplate(filename, timestamp)\n\n await CommandUtils.createFile(\n fullPath + (args.outputJs ? \".js\" : \".ts\"),\n fileContent,\n )\n console.log(\n `Migration ${chalk.blue(\n fullPath + (args.outputJs ? \".js\" : \".ts\"),\n )} has been generated successfully.`,\n )\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration creation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(name: string, timestamp: number): string {\n return `import { MigrationInterface, QueryRunner } from \"typeorm\"\n\nexport class ${camelCase(\n name,\n true,\n )}${timestamp} implements MigrationInterface {\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n ): string {\n return `const { MigrationInterface, QueryRunner } = require(\"typeorm\");\n\nmodule.exports = class ${camelCase(name, true)}${timestamp} {\n\n async up(queryRunner) {\n }\n\n async down(queryRunner) {\n }\n\n}\n`\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/commands/MigrationCreateCommand.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,qDAA+C;AAE/C,0DAAyB;AACzB,6DAAyD;AACzD,wDAAuB;AAEvB;;GAEG;AACH,MAAa,sBAAsB;IAAnC;QACI,YAAO,GAAG,yBAAyB,CAAA;QACnC,aAAQ,GAAG,+BAA+B,CAAA;IAqG9C,CAAC;IAnGG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,UAAU,CAAC,MAAM,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,4BAA4B;YACtC,YAAY,EAAE,IAAI;SACrB,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EACJ,+DAA+D;SACtE,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,yCAAyC;SACtD,CAAC,CAAA;IACV,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAA6C;QACvD,IAAI;YACA,MAAM,SAAS,GAAG,2BAAY,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CA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OAEG;IACO,MAAM,CAAC,qBAAqB,CAClC,IAAY,EACZ,SAAiB;QAEjB,OAAO;;yBAEU,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS;;;;;;;;;CASzD,CAAA;IACG,CAAC;CACJ;AAvGD,wDAuGC","file":"MigrationCreateCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\"\nimport { camelCase } from \"../util/StringUtils\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport path from \"path\"\n\n/**\n * Creates a new migration file.\n */\nexport class MigrationCreateCommand implements yargs.CommandModule {\n command = \"migration:create <path>\"\n describe = \"Creates a new migration file.\"\n\n builder(args: yargs.Argv) {\n return args\n .positional(\"path\", {\n type: \"string\",\n describe: \"Path of the migration file\",\n demandOption: true,\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments<any & { path: string }>) {\n try {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const inputPath = args.path.startsWith(\"/\")\n ? args.path\n : path.resolve(process.cwd(), args.path)\n const filename = path.basename(inputPath)\n const fullPath =\n path.dirname(inputPath) + \"/\" + timestamp + \"-\" + filename\n\n const fileContent = args.outputJs\n ? MigrationCreateCommand.getJavascriptTemplate(\n filename,\n timestamp,\n )\n : MigrationCreateCommand.getTemplate(filename, timestamp)\n\n await CommandUtils.createFile(\n fullPath + (args.outputJs ? \".js\" : \".ts\"),\n fileContent,\n )\n console.log(\n `Migration ${chalk.blue(\n fullPath + (args.outputJs ? \".js\" : \".ts\"),\n )} has been generated successfully.`,\n )\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration creation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(name: string, timestamp: number): string {\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${camelCase(\n name,\n true,\n )}${timestamp} implements MigrationInterface {\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n ): string {\n return `const { MigrationInterface, QueryRunner } = require(\"typeorm\");\n\nmodule.exports = class ${camelCase(name, true)}${timestamp} {\n\n async up(queryRunner) {\n }\n\n async down(queryRunner) {\n }\n\n}\n`\n }\n}\n"],"sourceRoot":".."}
@@ -6,6 +6,8 @@ export declare class MigrationGenerateCommand implements yargs.CommandModule {
6
6
  command: string;
7
7
  describe: string;
8
8
  builder(args: yargs.Argv): yargs.Argv<{
9
+ path: string;
10
+ } & {
9
11
  dataSource: string;
10
12
  } & {
11
13
  p: boolean;
@@ -18,7 +20,9 @@ export declare class MigrationGenerateCommand implements yargs.CommandModule {
18
20
  } & {
19
21
  t: number | boolean;
20
22
  }>;
21
- handler(args: yargs.Arguments): Promise<void>;
23
+ handler(args: yargs.Arguments<any & {
24
+ path: string;
25
+ }>): Promise<void>;
22
26
  /**
23
27
  * Formats query parameters for migration queries if parameters actually exist
24
28
  */
@@ -19,6 +19,11 @@ class MigrationGenerateCommand {
19
19
  }
20
20
  builder(args) {
21
21
  return args
22
+ .positional("path", {
23
+ type: "string",
24
+ describe: "Path of the migration file",
25
+ demandOption: true,
26
+ })
22
27
  .option("dataSource", {
23
28
  alias: "d",
24
29
  type: "string",
@@ -133,7 +138,9 @@ class MigrationGenerateCommand {
133
138
  const migrationFileName = path.dirname(fullPath) + "/" + filename;
134
139
  await CommandUtils_1.CommandUtils.createFile(migrationFileName, fileContent);
135
140
  console.log(chalk_1.default.green(`Migration ${chalk_1.default.blue(migrationFileName)} has been generated successfully.`));
136
- process_1.default.exit(0);
141
+ if (args.exitProcess !== false) {
142
+ process_1.default.exit(0);
143
+ }
137
144
  }
138
145
  }
139
146
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/MigrationGenerateCommand.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,qDAA+C;AAE/C,0DAAyB;AACzB,uEAA6D;AAC7D,6DAAyD;AAEzD,mDAA4B;AAC5B,8DAA6B;AAE7B;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACI,YAAO,GAAG,2BAA2B,CAAA;QACrC,aAAQ,GACJ,gFAAgF,CAAA;IAiRxF,CAAC;IA/QG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,MAAM,CAAC,YAAY,EAAE;YAClB,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EACJ,6DAA6D;YACjE,YAAY,EAAE,IAAI;SACrB,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,4BAA4B;SACzC,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EACJ,+DAA+D;SACtE,CAAC;aACD,MAAM,CAAC,IAAI,EAAE;YACV,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EACJ,0EAA0E;SACjF,CAAC;aACD,MAAM,CAAC,IAAI,EAAE;YACV,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EACJ,kHAAkH;SACzH,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,WAAW;YA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AAO;;yBAEU,aAAa;cACxB,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;CAGD,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,aAAa,CAAC,KAAa;QACxC,MAAM,cAAc,GAAG,IAAA,qBAAM,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACxD,OAAO,CACH,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,YAAY,CACtE,CAAA;IACL,CAAC;CACJ;AApRD,4DAoRC","file":"MigrationGenerateCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\"\nimport { camelCase } from \"../util/StringUtils\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { DataSource } from \"../data-source\"\nimport * as path from \"path\"\nimport process from \"process\"\n\n/**\n * Generates a new migration file with sql needs to be executed to update schema.\n */\nexport class MigrationGenerateCommand implements yargs.CommandModule {\n command = \"migration:generate <path>\"\n describe =\n \"Generates a new migration file with sql needs to be executed to update schema.\"\n\n builder(args: yargs.Argv) {\n return args\n .option(\"dataSource\", {\n alias: \"d\",\n type: \"string\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n .option(\"p\", {\n alias: \"pretty\",\n type: \"boolean\",\n default: false,\n describe: \"Pretty-print generated SQL\",\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"dr\", {\n alias: \"dryrun\",\n type: \"boolean\",\n default: false,\n describe:\n \"Prints out the contents of the migration instead of writing it to a file\",\n })\n .option(\"ch\", {\n alias: \"check\",\n type: \"boolean\",\n default: false,\n describe:\n \"Verifies that the current database is up to date and that no migrations are needed. Otherwise exits with code 1.\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments) {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const extension = args.outputJs ? \".js\" : \".ts\"\n const fullPath = (args.path as string).startsWith(\"/\")\n ? (args.path as string)\n : path.resolve(process.cwd(), args.path as string)\n const filename = timestamp + \"-\" + path.basename(fullPath) + extension\n\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n const upSqls: string[] = [],\n downSqls: string[] = []\n\n try {\n const sqlInMemory = await dataSource.driver\n .createSchemaBuilder()\n .log()\n\n if (args.pretty) {\n sqlInMemory.upQueries.forEach((upQuery) => {\n upQuery.query = MigrationGenerateCommand.prettifyQuery(\n upQuery.query,\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downQuery.query =\n MigrationGenerateCommand.prettifyQuery(\n downQuery.query,\n )\n })\n }\n\n sqlInMemory.upQueries.forEach((upQuery) => {\n upSqls.push(\n \" await queryRunner.query(`\" +\n upQuery.query.replace(new RegExp(\"`\", \"g\"), \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n upQuery.parameters,\n ) +\n \");\",\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downSqls.push(\n \" await queryRunner.query(`\" +\n downQuery.query.replace(\n new RegExp(\"`\", \"g\"),\n \"\\\\`\",\n ) +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n downQuery.parameters,\n ) +\n \");\",\n )\n })\n } finally {\n await dataSource.destroy()\n }\n\n if (!upSqls.length) {\n if (args.check) {\n console.log(\n chalk.green(`No changes in database schema were found`),\n )\n process.exit(0)\n } else {\n console.log(\n chalk.yellow(\n `No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n ),\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(chalk.yellow(\"Please specify a migration path\"))\n process.exit(1)\n }\n\n const fileContent = args.outputJs\n ? MigrationGenerateCommand.getJavascriptTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n : MigrationGenerateCommand.getTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n\n if (args.check) {\n console.log(\n chalk.yellow(\n `Unexpected changes in database schema were found in check mode:\\n\\n${chalk.white(\n fileContent,\n )}`,\n ),\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n fullPath + extension,\n )} has content:\\n\\n${chalk.white(fileContent)}`,\n ),\n )\n } else {\n const migrationFileName =\n path.dirname(fullPath) + \"/\" + filename\n await CommandUtils.createFile(migrationFileName, fileContent)\n\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n migrationFileName,\n )} has been generated successfully.`,\n ),\n )\n process.exit(0)\n }\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration generation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats query parameters for migration queries if parameters actually exist\n */\n protected static queryParams(parameters: any[] | undefined): string {\n if (!parameters || !parameters.length) {\n return \"\"\n }\n\n return `, ${JSON.stringify(parameters)}`\n }\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${migrationName} implements MigrationInterface {\n name = '${migrationName}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${upSqls.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${downSqls.join(`\n`)}\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `const { MigrationInterface, QueryRunner } = require(\"typeorm\");\n\nmodule.exports = class ${migrationName} {\n name = '${migrationName}'\n\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n async down(queryRunner) {\n${downSqls.join(`\n`)}\n }\n}\n`\n }\n\n /**\n *\n */\n protected static prettifyQuery(query: string) {\n const formattedQuery = format(query, { indent: \" \" })\n return (\n \"\\n\" + formattedQuery.replace(/^/gm, \" \") + \"\\n \"\n )\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/commands/MigrationGenerateCommand.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,qDAA+C;AAE/C,0DAAyB;AACzB,uEAA6D;AAC7D,6DAAyD;AAEzD,mDAA4B;AAC5B,8DAA6B;AAE7B;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACI,YAAO,GAAG,2BAA2B,CAAA;QACrC,aAAQ,GACJ,gFAAgF,CAAA;IAwRxF,CAAC;IAtRG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,UAAU,CAAC,MAAM,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,4BAA4B;YACtC,YAAY,EAAE,IAAI;SACrB,CAAC;aACD,MAAM,CAAC,YAAY,EAAE;YAClB,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EACJ,6DAA6D;YACjE,YAAY,EAAE,IAAI;SACrB,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,4BAA4B;SACz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ED;;OAEG;IACO,MAAM,CAAC,WAAW,CACxB,IAAY,EACZ,SAAiB,EACjB,MAAgB,EAChB,QAAkB;QAElB,MAAM,aAAa,GAAG,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,CAAA;QAE5D,OAAO;;eAEA,aAAa;cACd,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;;CAID,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,qBAAqB,CAClC,IAAY,EACZ,SAAiB,EACjB,MAAgB,EAChB,QAAkB;QAElB,MAAM,aAAa,GAAG,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,CAAA;QAE5D,OAAO;;yBAEU,aAAa;cACxB,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;CAGD,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,aAAa,CAAC,KAAa;QACxC,MAAM,cAAc,GAAG,IAAA,qBAAM,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACxD,OAAO,CACH,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,YAAY,CACtE,CAAA;IACL,CAAC;CACJ;AA3RD,4DA2RC","file":"MigrationGenerateCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\"\nimport { camelCase } from \"../util/StringUtils\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { DataSource } from \"../data-source\"\nimport * as path from \"path\"\nimport process from \"process\"\n\n/**\n * Generates a new migration file with sql needs to be executed to update schema.\n */\nexport class MigrationGenerateCommand implements yargs.CommandModule {\n command = \"migration:generate <path>\"\n describe =\n \"Generates a new migration file with sql needs to be executed to update schema.\"\n\n builder(args: yargs.Argv) {\n return args\n .positional(\"path\", {\n type: \"string\",\n describe: \"Path of the migration file\",\n demandOption: true,\n })\n .option(\"dataSource\", {\n alias: \"d\",\n type: \"string\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n .option(\"p\", {\n alias: \"pretty\",\n type: \"boolean\",\n default: false,\n describe: \"Pretty-print generated SQL\",\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"dr\", {\n alias: \"dryrun\",\n type: \"boolean\",\n default: false,\n describe:\n \"Prints out the contents of the migration instead of writing it to a file\",\n })\n .option(\"ch\", {\n alias: \"check\",\n type: \"boolean\",\n default: false,\n describe:\n \"Verifies that the current database is up to date and that no migrations are needed. Otherwise exits with code 1.\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments<any & { path: string }>) {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const extension = args.outputJs ? \".js\" : \".ts\"\n const fullPath = args.path.startsWith(\"/\")\n ? args.path\n : path.resolve(process.cwd(), args.path)\n const filename = timestamp + \"-\" + path.basename(fullPath) + extension\n\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n const upSqls: string[] = [],\n downSqls: string[] = []\n\n try {\n const sqlInMemory = await dataSource.driver\n .createSchemaBuilder()\n .log()\n\n if (args.pretty) {\n sqlInMemory.upQueries.forEach((upQuery) => {\n upQuery.query = MigrationGenerateCommand.prettifyQuery(\n upQuery.query,\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downQuery.query =\n MigrationGenerateCommand.prettifyQuery(\n downQuery.query,\n )\n })\n }\n\n sqlInMemory.upQueries.forEach((upQuery) => {\n upSqls.push(\n \" await queryRunner.query(`\" +\n upQuery.query.replace(new RegExp(\"`\", \"g\"), \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n upQuery.parameters,\n ) +\n \");\",\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downSqls.push(\n \" await queryRunner.query(`\" +\n downQuery.query.replace(\n new RegExp(\"`\", \"g\"),\n \"\\\\`\",\n ) +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n downQuery.parameters,\n ) +\n \");\",\n )\n })\n } finally {\n await dataSource.destroy()\n }\n\n if (!upSqls.length) {\n if (args.check) {\n console.log(\n chalk.green(`No changes in database schema were found`),\n )\n process.exit(0)\n } else {\n console.log(\n chalk.yellow(\n `No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n ),\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(chalk.yellow(\"Please specify a migration path\"))\n process.exit(1)\n }\n\n const fileContent = args.outputJs\n ? MigrationGenerateCommand.getJavascriptTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n : MigrationGenerateCommand.getTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n\n if (args.check) {\n console.log(\n chalk.yellow(\n `Unexpected changes in database schema were found in check mode:\\n\\n${chalk.white(\n fileContent,\n )}`,\n ),\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n fullPath + extension,\n )} has content:\\n\\n${chalk.white(fileContent)}`,\n ),\n )\n } else {\n const migrationFileName =\n path.dirname(fullPath) + \"/\" + filename\n await CommandUtils.createFile(migrationFileName, fileContent)\n\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n migrationFileName,\n )} has been generated successfully.`,\n ),\n )\n if (args.exitProcess !== false) {\n process.exit(0)\n }\n }\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration generation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats query parameters for migration queries if parameters actually exist\n */\n protected static queryParams(parameters: any[] | undefined): string {\n if (!parameters || !parameters.length) {\n return \"\"\n }\n\n return `, ${JSON.stringify(parameters)}`\n }\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${migrationName} implements MigrationInterface {\n name = '${migrationName}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${upSqls.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${downSqls.join(`\n`)}\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `const { MigrationInterface, QueryRunner } = require(\"typeorm\");\n\nmodule.exports = class ${migrationName} {\n name = '${migrationName}'\n\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n async down(queryRunner) {\n${downSqls.join(`\n`)}\n }\n}\n`\n }\n\n /**\n *\n */\n protected static prettifyQuery(query: string) {\n const formattedQuery = format(query, { indent: \" \" })\n return (\n \"\\n\" + formattedQuery.replace(/^/gm, \" \") + \"\\n \"\n )\n }\n}\n"],"sourceRoot":".."}
@@ -5,6 +5,9 @@ import * as yargs from "yargs";
5
5
  export declare class SubscriberCreateCommand implements yargs.CommandModule {
6
6
  command: string;
7
7
  describe: string;
8
+ builder(args: yargs.Argv): yargs.Argv<{
9
+ path: string;
10
+ }>;
8
11
  handler(args: yargs.Arguments): Promise<void>;
9
12
  /**
10
13
  * Gets contents of the entity file.
@@ -14,6 +14,13 @@ class SubscriberCreateCommand {
14
14
  this.command = "subscriber:create <path>";
15
15
  this.describe = "Generates a new subscriber.";
16
16
  }
17
+ builder(args) {
18
+ return args.positional("path", {
19
+ type: "string",
20
+ describe: "Path of the subscriber file",
21
+ demandOption: true,
22
+ });
23
+ }
17
24
  async handler(args) {
18
25
  try {
19
26
  const fullPath = args.path.startsWith("/")
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/SubscriberCreateCommand.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AACzB,wDAAuB;AACvB,6DAAyD;AACzD,iDAA6C;AAE7C;;GAEG;AACH,MAAa,uBAAuB;IAApC;QACI,YAAO,GAAG,0BAA0B,CAAA;QACpC,aAAQ,GAAG,6BAA6B,CAAA;IA2C5C,CAAC;IAzCG,KAAK,CAAC,OAAO,CAAC,IAAqB;QAC/B,IAAI;YACA,MAAM,QAAQ,GAAI,IAAI,CAAC,IAAe,CAAC,UAAU,CAAC,GAAG,CAAC;gBAClD,CAAC,CAAE,IAAI,CAAC,IAAe;gBACvB,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,IAAc,CAAC,CAAA;YACtD,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;YACxC,MAAM,WAAW,GAAG,uBAAuB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;YACjE,MAAM,UAAU,GAAG,MAAM,2BAAY,CAAC,UAAU,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAA;YAClE,IAAI,UAAU,EAAE;gBACZ,MAAM,QAAQ,eAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,iBAAiB,CAAA;aAC9D;YACD,MAAM,2BAAY,CAAC,UAAU,CAAC,QAAQ,GAAG,KAAK,EAAE,WAAW,CAAC,CAAA;YAC5D,OAAO,CAAC,GAAG,CACP,eAAK,CAAC,KAAK,CACP,cAAc,eAAK,CAAC,IAAI,CACpB,QAAQ,CACX,iCAAiC,CACrC,CACJ,CAAA;SACJ;QAAC,OAAO,GAAG,EAAE;YACV,6BAAa,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAA;YAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;SAClB;IACL,CAAC;IAED,4EAA4E;IAC5E,2BAA2B;IAC3B,4EAA4E;IAE5E;;OAEG;IACO,MAAM,CAAC,WAAW,CAAC,IAAY;QACrC,OAAO;;;eAGA,IAAI;;;CAGlB,CAAA;IACG,CAAC;CACJ;AA7CD,0DA6CC","file":"SubscriberCreateCommand.js","sourcesContent":["import * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport path from \"path\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Generates a new subscriber.\n */\nexport class SubscriberCreateCommand implements yargs.CommandModule {\n command = \"subscriber:create <path>\"\n describe = \"Generates a new subscriber.\"\n\n async handler(args: yargs.Arguments) {\n try {\n const fullPath = (args.path as string).startsWith(\"/\")\n ? (args.path as string)\n : path.resolve(process.cwd(), args.path as string)\n const filename = path.basename(fullPath)\n const fileContent = SubscriberCreateCommand.getTemplate(filename)\n const fileExists = await CommandUtils.fileExists(fullPath + \".ts\")\n if (fileExists) {\n throw `File ${chalk.blue(fullPath + \".ts\")} already exists`\n }\n await CommandUtils.createFile(fullPath + \".ts\", fileContent)\n console.log(\n chalk.green(\n `Subscriber ${chalk.blue(\n fullPath,\n )} has been created successfully.`,\n ),\n )\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during subscriber creation:\")\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets contents of the entity file.\n */\n protected static getTemplate(name: string): string {\n return `import { EventSubscriber, EntitySubscriberInterface } from \"typeorm\"\n\n@EventSubscriber()\nexport class ${name} implements EntitySubscriberInterface {\n\n}\n`\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/commands/SubscriberCreateCommand.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AACzB,wDAAuB;AACvB,6DAAyD;AACzD,iDAA6C;AAE7C;;GAEG;AACH,MAAa,uBAAuB;IAApC;QACI,YAAO,GAAG,0BAA0B,CAAA;QACpC,aAAQ,GAAG,6BAA6B,CAAA;IAmD5C,CAAC;IAjDG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAC3B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,6BAA6B;YACvC,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAqB;QAC/B,IAAI;YACA,MAAM,QAAQ,GAAI,IAAI,CAAC,IAAe,CAAC,UAAU,CAAC,GAAG,CAAC;gBAClD,CAAC,CAAE,IAAI,CAAC,IAAe;gBACvB,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,IAAc,CAAC,CAAA;YACtD,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;YACxC,MAAM,WAAW,GAAG,uBAAuB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;YACjE,MAAM,UAAU,GAAG,MAAM,2BAAY,CAAC,UAAU,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAA;YAClE,IAAI,UAAU,EAAE;gBACZ,MAAM,QAAQ,eAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,iBAAiB,CAAA;aAC9D;YACD,MAAM,2BAAY,CAAC,UAAU,CAAC,QAAQ,GAAG,KAAK,EAAE,WAAW,CAAC,CAAA;YAC5D,OAAO,CAAC,GAAG,CACP,eAAK,CAAC,KAAK,CACP,cAAc,eAAK,CAAC,IAAI,CACpB,QAAQ,CACX,iCAAiC,CACrC,CACJ,CAAA;SACJ;QAAC,OAAO,GAAG,EAAE;YACV,6BAAa,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAA;YAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;SAClB;IACL,CAAC;IAED,4EAA4E;IAC5E,2BAA2B;IAC3B,4EAA4E;IAE5E;;OAEG;IACO,MAAM,CAAC,WAAW,CAAC,IAAY;QACrC,OAAO;;;eAGA,IAAI;;;CAGlB,CAAA;IACG,CAAC;CACJ;AArDD,0DAqDC","file":"SubscriberCreateCommand.js","sourcesContent":["import * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport path from \"path\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Generates a new subscriber.\n */\nexport class SubscriberCreateCommand implements yargs.CommandModule {\n command = \"subscriber:create <path>\"\n describe = \"Generates a new subscriber.\"\n\n builder(args: yargs.Argv) {\n return args.positional(\"path\", {\n type: \"string\",\n describe: \"Path of the subscriber file\",\n demandOption: true,\n })\n }\n\n async handler(args: yargs.Arguments) {\n try {\n const fullPath = (args.path as string).startsWith(\"/\")\n ? (args.path as string)\n : path.resolve(process.cwd(), args.path as string)\n const filename = path.basename(fullPath)\n const fileContent = SubscriberCreateCommand.getTemplate(filename)\n const fileExists = await CommandUtils.fileExists(fullPath + \".ts\")\n if (fileExists) {\n throw `File ${chalk.blue(fullPath + \".ts\")} already exists`\n }\n await CommandUtils.createFile(fullPath + \".ts\", fileContent)\n console.log(\n chalk.green(\n `Subscriber ${chalk.blue(\n fullPath,\n )} has been created successfully.`,\n ),\n )\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during subscriber creation:\")\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets contents of the entity file.\n */\n protected static getTemplate(name: string): string {\n return `import { EventSubscriber, EntitySubscriberInterface } from \"typeorm\"\n\n@EventSubscriber()\nexport class ${name} implements EntitySubscriberInterface {\n\n}\n`\n }\n}\n"],"sourceRoot":".."}
@@ -93,11 +93,8 @@ class DriverUtils {
93
93
  * @return An alias that is no longer than the divers max alias length.
94
94
  */
95
95
  static buildAlias({ maxAliasLength }, buildOptions, ...alias) {
96
- const newAlias = alias.length === 1
97
- ? alias[0]
98
- : alias.join(buildOptions && buildOptions.joiner
99
- ? buildOptions.joiner
100
- : "_");
96
+ const joiner = buildOptions && buildOptions.joiner ? buildOptions.joiner : "_";
97
+ let newAlias = alias.length === 1 ? alias[0] : alias.join(joiner);
101
98
  if (maxAliasLength &&
102
99
  maxAliasLength > 0 &&
103
100
  newAlias.length > maxAliasLength) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/DriverUtils.ts"],"names":[],"mappings":";;;AACA,qDAAmD;AACnD,uDAAmD;AAEnD;;GAEG;AACH,MAAa,WAAW;IACpB,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,MAAc;QAChC,OAAO;YACH,QAAQ;YACR,SAAS;YACT,cAAc;YACd,cAAc;YACd,OAAO;YACP,MAAM;YACN,gBAAgB;YAChB,WAAW;SACd,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,MAAc;QAC/B,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7D,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,MAAc,EAAE,OAAe;QAC5D,OAAO,CACH,MAAM,CAAC,OAAO,IAAI,IAAI;YACtB,2BAA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I,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YACvC,QAAQ,EAAE,SAAS,IAAI,SAAS;SACnC,CAAA;QAED,uDAAuD;QACvD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YACtD,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SAC7B;QAED,OAAO,aAAa,CAAA;IACxB,CAAC;CACJ;AAvSD,kCAuSC","file":"DriverUtils.js","sourcesContent":["import { Driver } from \"./Driver\"\nimport { hash, shorten } from \"../util/StringUtils\"\nimport { VersionUtils } from \"../util/VersionUtils\"\n\n/**\n * Common driver utility functions.\n */\nexport class DriverUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns true if given driver is SQLite-based driver.\n */\n static isSQLiteFamily(driver: Driver): boolean {\n return [\n \"sqlite\",\n \"cordova\",\n \"react-native\",\n \"nativescript\",\n \"sqljs\",\n \"expo\",\n \"better-sqlite3\",\n \"capacitor\",\n ].includes(driver.options.type)\n }\n\n /**\n * Returns true if given driver is MySQL-based driver.\n */\n static isMySQLFamily(driver: Driver): boolean {\n return [\"mysql\", \"mariadb\"].includes(driver.options.type)\n }\n\n static isReleaseVersionOrGreater(driver: Driver, version: string): boolean {\n return (\n driver.version != null &&\n VersionUtils.isGreaterOrEqual(driver.version, version)\n )\n }\n\n static isPostgresFamily(driver: Driver): boolean {\n return [\"postgres\", \"aurora-postgres\", \"cockroachdb\"].includes(\n driver.options.type,\n )\n }\n\n /**\n * Normalizes and builds a new driver options.\n * Extracts settings from connection url and sets to a new options object.\n */\n static buildDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseConnectionUrl(options.url) as {\n [key: string]: any\n }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * buildDriverOptions for MongodDB only to support replica set\n */\n static buildMongoDBDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseMongoDBConnectionUrl(\n options.url,\n ) as { [key: string]: any }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * Joins and shortens alias if needed.\n *\n * If the alias length is greater than the limit allowed by the current\n * driver, replaces it with a shortend string, if the shortend string\n * is still too long, it will then hash the alias.\n *\n * @param driver Current `Driver`.\n * @param buildOptions Optional settings.\n * @param alias Alias parts.\n *\n * @return An alias that is no longer than the divers max alias length.\n */\n static buildAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | undefined,\n ...alias: string[]\n ): string {\n const newAlias =\n alias.length === 1\n ? alias[0]\n : alias.join(\n buildOptions && buildOptions.joiner\n ? buildOptions.joiner\n : \"_\",\n )\n if (\n maxAliasLength &&\n maxAliasLength > 0 &&\n newAlias.length > maxAliasLength\n ) {\n if (buildOptions && buildOptions.shorten === true) {\n const shortenedAlias = shorten(newAlias)\n if (shortenedAlias.length < maxAliasLength) {\n return shortenedAlias\n }\n }\n\n return hash(newAlias, { length: maxAliasLength })\n }\n\n return newAlias\n }\n\n /**\n * @deprecated use `buildAlias` instead.\n */\n static buildColumnAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | string,\n ...alias: string[]\n ) {\n if (typeof buildOptions === \"string\") {\n alias.unshift(buildOptions)\n buildOptions = { shorten: false, joiner: \"_\" }\n } else {\n buildOptions = Object.assign(\n { shorten: false, joiner: \"_\" },\n buildOptions,\n )\n }\n return this.buildAlias(\n { maxAliasLength } as Driver,\n buildOptions,\n ...alias,\n )\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Extracts connection data from the connection url.\n */\n private static parseConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n // remove mongodb query params\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n const [host, port] = hostAndPort.split(\":\")\n\n return {\n type: type,\n host: host,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n }\n\n /**\n * Extracts connection data from the connection url for MongoDB to support replica set.\n */\n private static parseMongoDBConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n let afterQuestionMark = \"\"\n let host = undefined\n let port = undefined\n let hostReplicaSet = undefined\n let replicaSet = undefined\n\n let optionsObject: any = {}\n\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n // split params\n afterQuestionMark = afterBase.substr(\n afterBase.indexOf(\"?\") + 1,\n afterBase.length,\n )\n\n const optionsList = afterQuestionMark.split(\"&\")\n let optionKey: string\n let optionValue: string\n\n // create optionsObject for merge with connectionUrl object before return\n optionsList.forEach((optionItem) => {\n optionKey = optionItem.split(\"=\")[0]\n optionValue = optionItem.split(\"=\")[1]\n optionsObject[optionKey] = optionValue\n })\n\n // specific replicaSet value to set options about hostReplicaSet\n replicaSet = optionsObject[\"replicaSet\"]\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n\n // If replicaSet have value set It as hostlist, If not set like standalone host\n if (replicaSet) {\n hostReplicaSet = hostAndPort\n } else {\n ;[host, port] = hostAndPort.split(\":\")\n }\n\n let connectionUrl: any = {\n type: type,\n host: host,\n hostReplicaSet: hostReplicaSet,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n\n // Loop to set every options in connectionUrl to object\n for (const [key, value] of Object.entries(optionsObject)) {\n connectionUrl[key] = value\n }\n\n return connectionUrl\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/driver/DriverUtils.ts"],"names":[],"mappings":";;;AACA,qDAAmD;AACnD,uDAAmD;AAEnD;;GAEG;AACH,MAAa,WAAW;IACpB,4EAA4E;IAC5E,wBAAwB;IACxB,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;YACnB,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;YACpD,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA;SACxD;QAED,+EAA+E;QAC/E,IAAI,UAAU,EAAE;YACZ,cAAc,GAAG,WAAW,CAAA;SAC/B;aAAM;YACH,CAAC;YAAA,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SACzC;QAED,IAAI,aAAa,GAAQ;YACrB,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,cAAc,EAAE,cAAc;YAC9B,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;YACtC,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;YACtC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YACvC,QAAQ,EAAE,SAAS,IAAI,SAAS;SACnC,CAAA;QAED,uDAAuD;QACvD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YACtD,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SAC7B;QAED,OAAO,aAAa,CAAA;IACxB,CAAC;CACJ;AApSD,kCAoSC","file":"DriverUtils.js","sourcesContent":["import { Driver } from \"./Driver\"\nimport { hash, shorten } from \"../util/StringUtils\"\nimport { VersionUtils } from \"../util/VersionUtils\"\n\n/**\n * Common driver utility functions.\n */\nexport class DriverUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns true if given driver is SQLite-based driver.\n */\n static isSQLiteFamily(driver: Driver): boolean {\n return [\n \"sqlite\",\n \"cordova\",\n \"react-native\",\n \"nativescript\",\n \"sqljs\",\n \"expo\",\n \"better-sqlite3\",\n \"capacitor\",\n ].includes(driver.options.type)\n }\n\n /**\n * Returns true if given driver is MySQL-based driver.\n */\n static isMySQLFamily(driver: Driver): boolean {\n return [\"mysql\", \"mariadb\"].includes(driver.options.type)\n }\n\n static isReleaseVersionOrGreater(driver: Driver, version: string): boolean {\n return (\n driver.version != null &&\n VersionUtils.isGreaterOrEqual(driver.version, version)\n )\n }\n\n static isPostgresFamily(driver: Driver): boolean {\n return [\"postgres\", \"aurora-postgres\", \"cockroachdb\"].includes(\n driver.options.type,\n )\n }\n\n /**\n * Normalizes and builds a new driver options.\n * Extracts settings from connection url and sets to a new options object.\n */\n static buildDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseConnectionUrl(options.url) as {\n [key: string]: any\n }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * buildDriverOptions for MongodDB only to support replica set\n */\n static buildMongoDBDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseMongoDBConnectionUrl(\n options.url,\n ) as { [key: string]: any }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * Joins and shortens alias if needed.\n *\n * If the alias length is greater than the limit allowed by the current\n * driver, replaces it with a shortend string, if the shortend string\n * is still too long, it will then hash the alias.\n *\n * @param driver Current `Driver`.\n * @param buildOptions Optional settings.\n * @param alias Alias parts.\n *\n * @return An alias that is no longer than the divers max alias length.\n */\n static buildAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | undefined,\n ...alias: string[]\n ): string {\n const joiner =\n buildOptions && buildOptions.joiner ? buildOptions.joiner : \"_\"\n\n let newAlias = alias.length === 1 ? alias[0] : alias.join(joiner)\n\n if (\n maxAliasLength &&\n maxAliasLength > 0 &&\n newAlias.length > maxAliasLength\n ) {\n if (buildOptions && buildOptions.shorten === true) {\n const shortenedAlias = shorten(newAlias)\n if (shortenedAlias.length < maxAliasLength) {\n return shortenedAlias\n }\n }\n\n return hash(newAlias, { length: maxAliasLength })\n }\n\n return newAlias\n }\n\n /**\n * @deprecated use `buildAlias` instead.\n */\n static buildColumnAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | string,\n ...alias: string[]\n ) {\n if (typeof buildOptions === \"string\") {\n alias.unshift(buildOptions)\n buildOptions = { shorten: false, joiner: \"_\" }\n } else {\n buildOptions = Object.assign(\n { shorten: false, joiner: \"_\" },\n buildOptions,\n )\n }\n return this.buildAlias(\n { maxAliasLength } as Driver,\n buildOptions,\n ...alias,\n )\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Extracts connection data from the connection url.\n */\n private static parseConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n // remove mongodb query params\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n const [host, port] = hostAndPort.split(\":\")\n\n return {\n type: type,\n host: host,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n }\n\n /**\n * Extracts connection data from the connection url for MongoDB to support replica set.\n */\n private static parseMongoDBConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n let afterQuestionMark = \"\"\n let host = undefined\n let port = undefined\n let hostReplicaSet = undefined\n let replicaSet = undefined\n\n let optionsObject: any = {}\n\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n // split params\n afterQuestionMark = afterBase.substr(\n afterBase.indexOf(\"?\") + 1,\n afterBase.length,\n )\n\n const optionsList = afterQuestionMark.split(\"&\")\n let optionKey: string\n let optionValue: string\n\n // create optionsObject for merge with connectionUrl object before return\n optionsList.forEach((optionItem) => {\n optionKey = optionItem.split(\"=\")[0]\n optionValue = optionItem.split(\"=\")[1]\n optionsObject[optionKey] = optionValue\n })\n\n // specific replicaSet value to set options about hostReplicaSet\n replicaSet = optionsObject[\"replicaSet\"]\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n\n // If replicaSet have value set It as hostlist, If not set like standalone host\n if (replicaSet) {\n hostReplicaSet = hostAndPort\n } else {\n ;[host, port] = hostAndPort.split(\":\")\n }\n\n let connectionUrl: any = {\n type: type,\n host: host,\n hostReplicaSet: hostReplicaSet,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n\n // Loop to set every options in connectionUrl to object\n for (const [key, value] of Object.entries(optionsObject)) {\n connectionUrl[key] = value\n }\n\n return connectionUrl\n }\n}\n"],"sourceRoot":".."}
@@ -120,15 +120,15 @@ export declare class MongoQueryRunner implements QueryRunner {
120
120
  /**
121
121
  * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
122
122
  */
123
- findOneAndDelete(collectionName: string, filter: Filter<Document>, options?: FindOneAndDeleteOptions): Promise<Document>;
123
+ findOneAndDelete(collectionName: string, filter: Filter<Document>, options?: FindOneAndDeleteOptions): Promise<Document | null>;
124
124
  /**
125
125
  * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
126
126
  */
127
- findOneAndReplace(collectionName: string, filter: Filter<Document>, replacement: Document, options?: FindOneAndReplaceOptions): Promise<Document>;
127
+ findOneAndReplace(collectionName: string, filter: Filter<Document>, replacement: Document, options?: FindOneAndReplaceOptions): Promise<Document | null>;
128
128
  /**
129
129
  * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
130
130
  */
131
- findOneAndUpdate(collectionName: string, filter: Filter<Document>, update: UpdateFilter<Document>, options?: FindOneAndUpdateOptions): Promise<Document>;
131
+ findOneAndUpdate(collectionName: string, filter: Filter<Document>, update: UpdateFilter<Document>, options?: FindOneAndUpdateOptions): Promise<Document | null>;
132
132
  /**
133
133
  * Retrieve all the indexes on the collection.
134
134
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/mongodb/MongoQueryRunner.ts"],"names":[],"mappings":";;;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B,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;;;;OAKG;IACH,gBAAgB;QACZ,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;OAEG;IACH,cAAc;QACV,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;OAEG;IACH,YAAY;QACR,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB;QACpB,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB;QACtB,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;IACO,aAAa,CAAC,cAAsB;QAC1C,OAAO,IAAI,CAAC,kBAAkB;aACzB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAS,CAAC;aACpC,UAAU,CAAC,cAAc,CAAC,CAAA;IACnC,CAAC;CACJ;AAlrCD,4CAkrCC","file":"MongoQueryRunner.js","sourcesContent":["import { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { TableColumn } from \"../../schema-builder/table/TableColumn\"\nimport { Table } from \"../../schema-builder/table/Table\"\nimport { TableForeignKey } from \"../../schema-builder/table/TableForeignKey\"\nimport { TableIndex } from \"../../schema-builder/table/TableIndex\"\nimport { View } from \"../../schema-builder/view/View\"\n// import {Connection} from \"../../connection/Connection\";\nimport { ReadStream } from \"../../platform/PlatformTools\"\nimport { MongoEntityManager } from \"../../entity-manager/MongoEntityManager\"\nimport { SqlInMemory } from \"../SqlInMemory\"\nimport { TableUnique } from \"../../schema-builder/table/TableUnique\"\nimport { Broadcaster } from \"../../subscriber/Broadcaster\"\nimport { TableCheck } from \"../../schema-builder/table/TableCheck\"\nimport { TableExclusion } from \"../../schema-builder/table/TableExclusion\"\nimport { TypeORMError } from \"../../error\"\n\nimport {\n BulkWriteResult,\n AggregationCursor,\n MongoClient,\n Collection,\n FindCursor,\n Document,\n AggregateOptions,\n AnyBulkWriteOperation,\n BulkWriteOptions,\n Filter,\n CountOptions,\n CountDocumentsOptions,\n IndexSpecification,\n CreateIndexesOptions,\n IndexDescription,\n DeleteResult,\n DeleteOptions,\n CommandOperationOptions,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n UpdateFilter,\n FindOneAndUpdateOptions,\n RenameOptions,\n ReplaceOptions,\n UpdateResult,\n CollStats,\n CollStatsOptions,\n ChangeStreamOptions,\n ChangeStream,\n UpdateOptions,\n ListIndexesOptions,\n ListIndexesCursor,\n OptionalId,\n InsertOneOptions,\n InsertOneResult,\n InsertManyResult,\n UnorderedBulkOperation,\n OrderedBulkOperation,\n IndexInformationOptions,\n} from \"../../driver/mongodb/typings\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\n\n/**\n * Runs queries on a single MongoDB connection.\n */\nexport class MongoQueryRunner implements QueryRunner {\n // -------------------------------------------------------------------------\n // Public Implemented Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by this query runner.\n */\n connection: DataSource\n\n /**\n * Broadcaster used on this query runner to broadcast entity events.\n */\n broadcaster: Broadcaster\n\n /**\n * Entity manager working only with current query runner.\n */\n manager: MongoEntityManager\n\n /**\n * Indicates if connection for this query runner is released.\n * Once its released, query runner cannot run queries anymore.\n * Always false for mongodb since mongodb has a single query executor instance.\n */\n isReleased = false\n\n /**\n * Indicates if transaction is active in this query executor.\n * Always false for mongodb since mongodb does not support transactions.\n */\n isTransactionActive = false\n\n /**\n * Stores temporarily user data.\n * Useful for sharing data with subscribers.\n */\n data = {}\n\n /**\n * All synchronized tables in the database.\n */\n loadedTables: Table[]\n\n /**\n * All synchronized views in the database.\n */\n loadedViews: View[]\n\n /**\n * Real database connection from a connection pool used to perform queries.\n */\n databaseConnection: MongoClient\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource, databaseConnection: MongoClient) {\n this.connection = connection\n this.databaseConnection = databaseConnection\n this.broadcaster = new Broadcaster(this)\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Called before migrations are run.\n */\n async beforeMigration(): Promise<void> {\n // Do nothing\n }\n\n /**\n * Called after migrations are run.\n */\n async afterMigration(): Promise<void> {\n // Do nothing\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n */\n cursor(collectionName: string, filter: Filter<Document>): FindCursor<any> {\n return this.getCollection(collectionName).find(filter || {})\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n */\n aggregate(\n collectionName: string,\n pipeline: Document[],\n options?: AggregateOptions,\n ): AggregationCursor<any> {\n return this.getCollection(collectionName).aggregate(\n pipeline,\n options || {},\n )\n }\n\n /**\n * Perform a bulkWrite operation without a fluent API.\n */\n async bulkWrite(\n collectionName: string,\n operations: AnyBulkWriteOperation<Document>[],\n options?: BulkWriteOptions,\n ): Promise<BulkWriteResult> {\n return await this.getCollection(collectionName).bulkWrite(\n operations,\n options || {},\n )\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n async count(\n collectionName: string,\n filter: Filter<Document>,\n options?: CountOptions,\n ): Promise<number> {\n return this.getCollection(collectionName).count(\n filter || {},\n options || {},\n )\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n async countDocuments(\n collectionName: string,\n filter: Filter<Document>,\n options?: CountDocumentsOptions,\n ): Promise<any> {\n return this.getCollection(collectionName).countDocuments(\n filter || {},\n options || {},\n )\n }\n\n /**\n * Creates an index on the db and collection.\n */\n async createCollectionIndex(\n collectionName: string,\n indexSpec: IndexSpecification,\n options?: CreateIndexesOptions,\n ): Promise<string> {\n return this.getCollection(collectionName).createIndex(\n indexSpec,\n options || {},\n )\n }\n\n /**\n * Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.\n * Earlier version of MongoDB will throw a command not supported error. Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.\n */\n async createCollectionIndexes(\n collectionName: string,\n indexSpecs: IndexDescription[],\n ): Promise<string[]> {\n return this.getCollection(collectionName).createIndexes(indexSpecs)\n }\n\n /**\n * Delete multiple documents on MongoDB.\n */\n async deleteMany(\n collectionName: string,\n filter: Filter<Document>,\n options: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.getCollection(collectionName).deleteMany(\n filter,\n options || {},\n )\n }\n\n /**\n * Delete a document on MongoDB.\n */\n async deleteOne(\n collectionName: string,\n filter: Filter<Document>,\n options?: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.getCollection(collectionName).deleteOne(\n filter,\n options || {},\n )\n }\n\n /**\n * The distinct command returns returns a list of distinct values for the given key across a collection.\n */\n async distinct(\n collectionName: string,\n key: any,\n filter: Filter<Document>,\n options?: CommandOperationOptions,\n ): Promise<any> {\n return this.getCollection(collectionName).distinct(\n key,\n filter,\n options || {},\n )\n }\n\n /**\n * Drops an index from this collection.\n */\n async dropCollectionIndex(\n collectionName: string,\n indexName: string,\n options?: CommandOperationOptions,\n ): Promise<Document> {\n return this.getCollection(collectionName).dropIndex(\n indexName,\n options || {},\n )\n }\n\n /**\n * Drops all indexes from the collection.\n */\n async dropCollectionIndexes(collectionName: string): Promise<Document> {\n return this.getCollection(collectionName).dropIndexes()\n }\n\n /**\n * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.\n */\n async findOneAndDelete(\n collectionName: string,\n filter: Filter<Document>,\n options?: FindOneAndDeleteOptions,\n ): Promise<Document> {\n return this.getCollection(collectionName).findOneAndDelete(\n filter,\n options || {},\n )\n }\n\n /**\n * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.\n */\n async findOneAndReplace(\n collectionName: string,\n filter: Filter<Document>,\n replacement: Document,\n options?: FindOneAndReplaceOptions,\n ): Promise<Document> {\n return this.getCollection(collectionName).findOneAndReplace(\n filter,\n replacement,\n options || {},\n )\n }\n\n /**\n * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.\n */\n async findOneAndUpdate(\n collectionName: string,\n filter: Filter<Document>,\n update: UpdateFilter<Document>,\n options?: FindOneAndUpdateOptions,\n ): Promise<Document> {\n return this.getCollection(collectionName).findOneAndUpdate(\n filter,\n update,\n options || {},\n )\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n async collectionIndexes(collectionName: string): Promise<Document> {\n return this.getCollection(collectionName).indexes()\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n async collectionIndexExists(\n collectionName: string,\n indexes: string | string[],\n ): Promise<boolean> {\n return this.getCollection(collectionName).indexExists(indexes)\n }\n\n /**\n * Retrieves this collections index info.\n */\n async collectionIndexInformation(\n collectionName: string,\n options?: IndexInformationOptions,\n ): Promise<any> {\n return this.getCollection(collectionName).indexInformation(\n options || {},\n )\n }\n\n /**\n * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.\n */\n initializeOrderedBulkOp(\n collectionName: string,\n options?: BulkWriteOptions,\n ): OrderedBulkOperation {\n return this.getCollection(collectionName).initializeOrderedBulkOp(\n options,\n )\n }\n\n /**\n * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.\n */\n initializeUnorderedBulkOp(\n collectionName: string,\n options?: BulkWriteOptions,\n ): UnorderedBulkOperation {\n return this.getCollection(collectionName).initializeUnorderedBulkOp(\n options,\n )\n }\n\n /**\n * Inserts an array of documents into MongoDB.\n */\n async insertMany(\n collectionName: string,\n docs: OptionalId<Document>[],\n options?: BulkWriteOptions,\n ): Promise<InsertManyResult> {\n return this.getCollection(collectionName).insertMany(\n docs,\n options || {},\n )\n }\n\n /**\n * Inserts a single document into MongoDB.\n */\n async insertOne(\n collectionName: string,\n doc: OptionalId<Document>,\n options?: InsertOneOptions,\n ): Promise<InsertOneResult> {\n return this.getCollection(collectionName).insertOne(doc, options || {})\n }\n\n /**\n * Returns if the collection is a capped collection.\n */\n async isCapped(collectionName: string): Promise<boolean> {\n return this.getCollection(collectionName).isCapped()\n }\n\n /**\n * Get the list of all indexes information for the collection.\n */\n listCollectionIndexes(\n collectionName: string,\n options?: ListIndexesOptions,\n ): ListIndexesCursor {\n return this.getCollection(collectionName).listIndexes(options)\n }\n\n /**\n * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.\n */\n async rename(\n collectionName: string,\n newName: string,\n options?: RenameOptions,\n ): Promise<Collection<Document>> {\n return this.getCollection(collectionName).rename(newName, options || {})\n }\n\n /**\n * Replace a document on MongoDB.\n */\n async replaceOne(\n collectionName: string,\n filter: Filter<Document>,\n replacement: Document,\n options?: ReplaceOptions,\n ): Promise<Document | UpdateResult> {\n return this.getCollection(collectionName).replaceOne(\n filter,\n replacement,\n options || {},\n )\n }\n\n /**\n * Get all the collection statistics.\n */\n async stats(\n collectionName: string,\n options?: CollStatsOptions,\n ): Promise<CollStats> {\n return this.getCollection(collectionName).stats(options || {})\n }\n\n /**\n * Watching new changes as stream.\n */\n watch(\n collectionName: string,\n pipeline?: Document[],\n options?: ChangeStreamOptions,\n ): ChangeStream {\n return this.getCollection(collectionName).watch(pipeline, options)\n }\n\n /**\n * Update multiple documents on MongoDB.\n */\n async updateMany(\n collectionName: string,\n filter: Filter<Document>,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return this.getCollection(collectionName).updateMany(\n filter,\n update,\n options || {},\n )\n }\n\n /**\n * Update a single document on MongoDB.\n */\n async updateOne(\n collectionName: string,\n filter: Filter<Document>,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return await this.getCollection(collectionName).updateOne(\n filter,\n update,\n options || {},\n )\n }\n\n // -------------------------------------------------------------------------\n // Public Implemented Methods (from QueryRunner)\n // -------------------------------------------------------------------------\n\n /**\n * Removes all collections from the currently connected database.\n * Be careful with using this method and avoid using it in production or migrations\n * (because it can clear all your database).\n */\n async clearDatabase(): Promise<void> {\n await this.databaseConnection\n .db(this.connection.driver.database!)\n .dropDatabase()\n }\n\n /**\n * For MongoDB database we don't create connection, because its single connection already created by a driver.\n */\n async connect(): Promise<any> {}\n\n /**\n * For MongoDB database we don't release connection, because its single connection.\n */\n async release(): Promise<void> {\n // releasing connection are not supported by mongodb driver, so simply don't do anything here\n }\n\n /**\n * Starts transaction.\n */\n async startTransaction(): Promise<void> {\n // transactions are not supported by mongodb driver, so simply don't do anything here\n }\n\n /**\n * Commits transaction.\n */\n async commitTransaction(): Promise<void> {\n // transactions are not supported by mongodb driver, so simply don't do anything here\n }\n\n /**\n * Rollbacks transaction.\n */\n async rollbackTransaction(): Promise<void> {\n // transactions are not supported by mongodb driver, so simply don't do anything here\n }\n\n /**\n * Executes a given SQL query.\n */\n query(query: string, parameters?: any[]): Promise<any> {\n throw new TypeORMError(\n `Executing SQL query is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Returns raw data stream.\n */\n stream(\n query: string,\n parameters?: any[],\n onEnd?: Function,\n onError?: Function,\n ): Promise<ReadStream> {\n throw new TypeORMError(\n `Stream is not supported by MongoDB driver. Use watch instead.`,\n )\n }\n\n /**\n * Insert a new row with given values into the given table.\n * Returns value of inserted object id.\n\n async insert(collectionName: string, keyValues: ObjectLiteral): Promise<any> { // todo: fix any\n const results = await this.databaseConnection\n .collection(collectionName)\n .insertOne(keyValues);\n const generatedMap = this.connection.getMetadata(collectionName).objectIdColumn!.createValueMap(results.insertedId);\n return {\n result: results,\n generatedMap: generatedMap\n };\n }*/\n\n /**\n * Updates rows that match given conditions in the given table.\n\n async update(collectionName: string, valuesMap: ObjectLiteral, conditions: ObjectLiteral): Promise<any> { // todo: fix any\n await this.databaseConnection\n .collection(collectionName)\n .updateOne(conditions, valuesMap);\n }*/\n\n /**\n * Deletes from the given table by a given conditions.\n\n async delete(collectionName: string, conditions: ObjectLiteral|ObjectLiteral[]|string, maybeParameters?: any[]): Promise<any> { // todo: fix any\n if (typeof conditions === \"string\")\n throw new TypeORMError(`String condition is not supported by MongoDB driver.`);\n\n await this.databaseConnection\n .collection(collectionName)\n .deleteOne(conditions);\n }*/\n\n /**\n * Returns all available database names including system databases.\n */\n async getDatabases(): Promise<string[]> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Returns all available schema names including system schemas.\n * If database parameter specified, returns schemas of that database.\n */\n async getSchemas(database?: string): Promise<string[]> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads given table's data from the database.\n */\n async getTable(collectionName: string): Promise<Table | undefined> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads all tables (with given names) from the database and creates a Table from them.\n */\n async getTables(collectionNames: string[]): Promise<Table[]> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads given views's data from the database.\n */\n async getView(collectionName: string): Promise<View | undefined> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads all views (with given names) from the database and creates a Table from them.\n */\n async getViews(collectionNames: string[]): Promise<View[]> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n getReplicationMode(): ReplicationMode {\n return \"master\"\n }\n\n /**\n * Checks if database with the given name exist.\n */\n async hasDatabase(database: string): Promise<boolean> {\n throw new TypeORMError(\n `Check database queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads currently using database\n */\n async getCurrentDatabase(): Promise<undefined> {\n throw new TypeORMError(\n `Check database queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Checks if schema with the given name exist.\n */\n async hasSchema(schema: string): Promise<boolean> {\n throw new TypeORMError(\n `Check schema queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads currently using database schema\n */\n async getCurrentSchema(): Promise<undefined> {\n throw new TypeORMError(\n `Check schema queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Checks if table with the given name exist in the database.\n */\n async hasTable(collectionName: string): Promise<boolean> {\n throw new TypeORMError(\n `Check schema queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Checks if column with the given name exist in the given table.\n */\n async hasColumn(\n tableOrName: Table | string,\n columnName: string,\n ): Promise<boolean> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a database if it's not created.\n */\n async createDatabase(database: string): Promise<void> {\n throw new TypeORMError(\n `Database create queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops database.\n */\n async dropDatabase(database: string, ifExist?: boolean): Promise<void> {\n throw new TypeORMError(\n `Database drop queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new table schema.\n */\n async createSchema(\n schemaPath: string,\n ifNotExist?: boolean,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema create queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops table schema.\n */\n async dropSchema(schemaPath: string, ifExist?: boolean): Promise<void> {\n throw new TypeORMError(\n `Schema drop queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new table from the given table and columns inside it.\n */\n async createTable(table: Table): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops the table.\n */\n async dropTable(tableName: Table | string): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new view.\n */\n async createView(view: View): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops the view.\n */\n async dropView(target: View | string): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Renames the given table.\n */\n async renameTable(\n oldTableOrName: Table | string,\n newTableOrName: Table | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new column from the column in the table.\n */\n async addColumn(\n tableOrName: Table | string,\n column: TableColumn,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new columns from the column in the table.\n */\n async addColumns(\n tableOrName: Table | string,\n columns: TableColumn[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Renames column in the given table.\n */\n async renameColumn(\n tableOrName: Table | string,\n oldTableColumnOrName: TableColumn | string,\n newTableColumnOrName: TableColumn | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Changes a column in the table.\n */\n async changeColumn(\n tableOrName: Table | string,\n oldTableColumnOrName: TableColumn | string,\n newColumn: TableColumn,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Changes a column in the table.\n */\n async changeColumns(\n tableOrName: Table | string,\n changedColumns: { newColumn: TableColumn; oldColumn: TableColumn }[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops column in the table.\n */\n async dropColumn(\n tableOrName: Table | string,\n columnOrName: TableColumn | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops the columns in the table.\n */\n async dropColumns(\n tableOrName: Table | string,\n columns: TableColumn[] | string[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new primary key.\n */\n async createPrimaryKey(\n tableOrName: Table | string,\n columnNames: string[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Updates composite primary keys.\n */\n async updatePrimaryKeys(\n tableOrName: Table | string,\n columns: TableColumn[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops a primary key.\n */\n async dropPrimaryKey(tableOrName: Table | string): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new unique constraint.\n */\n async createUniqueConstraint(\n tableOrName: Table | string,\n uniqueConstraint: TableUnique,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new unique constraints.\n */\n async createUniqueConstraints(\n tableOrName: Table | string,\n uniqueConstraints: TableUnique[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops an unique constraint.\n */\n async dropUniqueConstraint(\n tableOrName: Table | string,\n uniqueOrName: TableUnique | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops an unique constraints.\n */\n async dropUniqueConstraints(\n tableOrName: Table | string,\n uniqueConstraints: TableUnique[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new check constraint.\n */\n async createCheckConstraint(\n tableOrName: Table | string,\n checkConstraint: TableCheck,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new check constraints.\n */\n async createCheckConstraints(\n tableOrName: Table | string,\n checkConstraints: TableCheck[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops check constraint.\n */\n async dropCheckConstraint(\n tableOrName: Table | string,\n checkOrName: TableCheck | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops check constraints.\n */\n async dropCheckConstraints(\n tableOrName: Table | string,\n checkConstraints: TableCheck[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new exclusion constraint.\n */\n async createExclusionConstraint(\n tableOrName: Table | string,\n exclusionConstraint: TableExclusion,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new exclusion constraints.\n */\n async createExclusionConstraints(\n tableOrName: Table | string,\n exclusionConstraints: TableExclusion[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops exclusion constraint.\n */\n async dropExclusionConstraint(\n tableOrName: Table | string,\n exclusionOrName: TableExclusion | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops exclusion constraints.\n */\n async dropExclusionConstraints(\n tableOrName: Table | string,\n exclusionConstraints: TableExclusion[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new foreign key.\n */\n async createForeignKey(\n tableOrName: Table | string,\n foreignKey: TableForeignKey,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new foreign keys.\n */\n async createForeignKeys(\n tableOrName: Table | string,\n foreignKeys: TableForeignKey[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops a foreign key from the table.\n */\n async dropForeignKey(\n tableOrName: Table | string,\n foreignKey: TableForeignKey,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops a foreign keys from the table.\n */\n async dropForeignKeys(\n tableOrName: Table | string,\n foreignKeys: TableForeignKey[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new index.\n */\n async createIndex(\n tableOrName: Table | string,\n index: TableIndex,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new indices\n */\n async createIndices(\n tableOrName: Table | string,\n indices: TableIndex[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops an index from the table.\n */\n async dropIndex(collectionName: string, indexName: string): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops an indices from the table.\n */\n async dropIndices(\n tableOrName: Table | string,\n indices: TableIndex[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops collection.\n */\n async clearTable(collectionName: string): Promise<void> {\n await this.databaseConnection\n .db(this.connection.driver.database!)\n .dropCollection(collectionName)\n }\n\n /**\n * Enables special query runner mode in which sql queries won't be executed,\n * instead they will be memorized into a special variable inside query runner.\n * You can get memorized sql using getMemorySql() method.\n */\n enableSqlMemory(): void {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Disables special query runner mode in which sql queries won't be executed\n * started by calling enableSqlMemory() method.\n *\n * Previously memorized sql will be flushed.\n */\n disableSqlMemory(): void {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Flushes all memorized sqls.\n */\n clearSqlMemory(): void {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Gets sql stored in the memory. Parameters in the sql are already replaced.\n */\n getMemorySql(): SqlInMemory {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Executes up sql queries.\n */\n async executeMemoryUpSql(): Promise<void> {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Executes down sql queries.\n */\n async executeMemoryDownSql(): Promise<void> {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets collection from the database with a given name.\n */\n protected getCollection(collectionName: string): Collection<any> {\n return this.databaseConnection\n .db(this.connection.driver.database!)\n .collection(collectionName)\n }\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/driver/mongodb/MongoQueryRunner.ts"],"names":[],"mappings":";;;AAWA,8DAA0D;AAG1D,uCAA0C;AA8C1C;;GAEG;AACH,MAAa,gBAAgB;IAsDzB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,UAAsB,EAAE,kBAA+B;QAtCnE;;;;WAIG;QACH,eAAU,GAAG,KAAK,CAAA;QAElB;;;WAGG;QACH,wBAAmB,GAAG,KAAK,CAAA;QAE3B;;;WAGG;QACH,SAAI,GAAG,EAAE,CAAA;QAsBL,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,eAAe;QACjB,aAAa;IACjB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc;QAChB,aAAa;IACjB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAsB,EAAE,MAAwB;QACnD,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;IAChE,CAAC;IAED;;OAEG;IACH,SAAS,CACL,cAAsB,EACtB,QAAoB,EACpB,OAA0B;QAE1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,CAAA;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACb,WAA2B,EAC3B,OAAqB;QAErB,MAAM,IAAI,oBAAY,CAClB,4DAA4D,CAC/D,CAAA;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,cAAsB;QACnC,MAAM,IAAI,CAAC,kBAAkB;aACxB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAS,CAAC;aACpC,cAAc,CAAC,cAAc,CAAC,CAAA;IACvC,CAAC;IAED;;;;OAIG;IACH,eAAe;QACX,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;;;;OAKG;IACH,gBAAgB;QACZ,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;OAEG;IACH,cAAc;QACV,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;OAEG;IACH,YAAY;QACR,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB;QACpB,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB;QACtB,MAAM,IAAI,oBAAY,CAClB,oDAAoD,CACvD,CAAA;IACL,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;IACO,aAAa,CAAC,cAAsB;QAC1C,OAAO,IAAI,CAAC,kBAAkB;aACzB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAS,CAAC;aACpC,UAAU,CAAC,cAAc,CAAC,CAAA;IACnC,CAAC;CACJ;AAlrCD,4CAkrCC","file":"MongoQueryRunner.js","sourcesContent":["import { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { TableColumn } from \"../../schema-builder/table/TableColumn\"\nimport { Table } from \"../../schema-builder/table/Table\"\nimport { TableForeignKey } from \"../../schema-builder/table/TableForeignKey\"\nimport { TableIndex } from \"../../schema-builder/table/TableIndex\"\nimport { View } from \"../../schema-builder/view/View\"\n// import {Connection} from \"../../connection/Connection\";\nimport { ReadStream } from \"../../platform/PlatformTools\"\nimport { MongoEntityManager } from \"../../entity-manager/MongoEntityManager\"\nimport { SqlInMemory } from \"../SqlInMemory\"\nimport { TableUnique } from \"../../schema-builder/table/TableUnique\"\nimport { Broadcaster } from \"../../subscriber/Broadcaster\"\nimport { TableCheck } from \"../../schema-builder/table/TableCheck\"\nimport { TableExclusion } from \"../../schema-builder/table/TableExclusion\"\nimport { TypeORMError } from \"../../error\"\n\nimport {\n BulkWriteResult,\n AggregationCursor,\n MongoClient,\n Collection,\n FindCursor,\n Document,\n AggregateOptions,\n AnyBulkWriteOperation,\n BulkWriteOptions,\n Filter,\n CountOptions,\n CountDocumentsOptions,\n IndexSpecification,\n CreateIndexesOptions,\n IndexDescription,\n DeleteResult,\n DeleteOptions,\n CommandOperationOptions,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n UpdateFilter,\n FindOneAndUpdateOptions,\n RenameOptions,\n ReplaceOptions,\n UpdateResult,\n CollStats,\n CollStatsOptions,\n ChangeStreamOptions,\n ChangeStream,\n UpdateOptions,\n ListIndexesOptions,\n ListIndexesCursor,\n OptionalId,\n InsertOneOptions,\n InsertOneResult,\n InsertManyResult,\n UnorderedBulkOperation,\n OrderedBulkOperation,\n IndexInformationOptions,\n} from \"../../driver/mongodb/typings\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\n\n/**\n * Runs queries on a single MongoDB connection.\n */\nexport class MongoQueryRunner implements QueryRunner {\n // -------------------------------------------------------------------------\n // Public Implemented Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by this query runner.\n */\n connection: DataSource\n\n /**\n * Broadcaster used on this query runner to broadcast entity events.\n */\n broadcaster: Broadcaster\n\n /**\n * Entity manager working only with current query runner.\n */\n manager: MongoEntityManager\n\n /**\n * Indicates if connection for this query runner is released.\n * Once its released, query runner cannot run queries anymore.\n * Always false for mongodb since mongodb has a single query executor instance.\n */\n isReleased = false\n\n /**\n * Indicates if transaction is active in this query executor.\n * Always false for mongodb since mongodb does not support transactions.\n */\n isTransactionActive = false\n\n /**\n * Stores temporarily user data.\n * Useful for sharing data with subscribers.\n */\n data = {}\n\n /**\n * All synchronized tables in the database.\n */\n loadedTables: Table[]\n\n /**\n * All synchronized views in the database.\n */\n loadedViews: View[]\n\n /**\n * Real database connection from a connection pool used to perform queries.\n */\n databaseConnection: MongoClient\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource, databaseConnection: MongoClient) {\n this.connection = connection\n this.databaseConnection = databaseConnection\n this.broadcaster = new Broadcaster(this)\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Called before migrations are run.\n */\n async beforeMigration(): Promise<void> {\n // Do nothing\n }\n\n /**\n * Called after migrations are run.\n */\n async afterMigration(): Promise<void> {\n // Do nothing\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n */\n cursor(collectionName: string, filter: Filter<Document>): FindCursor<any> {\n return this.getCollection(collectionName).find(filter || {})\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n */\n aggregate(\n collectionName: string,\n pipeline: Document[],\n options?: AggregateOptions,\n ): AggregationCursor<any> {\n return this.getCollection(collectionName).aggregate(\n pipeline,\n options || {},\n )\n }\n\n /**\n * Perform a bulkWrite operation without a fluent API.\n */\n async bulkWrite(\n collectionName: string,\n operations: AnyBulkWriteOperation<Document>[],\n options?: BulkWriteOptions,\n ): Promise<BulkWriteResult> {\n return await this.getCollection(collectionName).bulkWrite(\n operations,\n options || {},\n )\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n async count(\n collectionName: string,\n filter: Filter<Document>,\n options?: CountOptions,\n ): Promise<number> {\n return this.getCollection(collectionName).count(\n filter || {},\n options || {},\n )\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n async countDocuments(\n collectionName: string,\n filter: Filter<Document>,\n options?: CountDocumentsOptions,\n ): Promise<any> {\n return this.getCollection(collectionName).countDocuments(\n filter || {},\n options || {},\n )\n }\n\n /**\n * Creates an index on the db and collection.\n */\n async createCollectionIndex(\n collectionName: string,\n indexSpec: IndexSpecification,\n options?: CreateIndexesOptions,\n ): Promise<string> {\n return this.getCollection(collectionName).createIndex(\n indexSpec,\n options || {},\n )\n }\n\n /**\n * Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.\n * Earlier version of MongoDB will throw a command not supported error. Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.\n */\n async createCollectionIndexes(\n collectionName: string,\n indexSpecs: IndexDescription[],\n ): Promise<string[]> {\n return this.getCollection(collectionName).createIndexes(indexSpecs)\n }\n\n /**\n * Delete multiple documents on MongoDB.\n */\n async deleteMany(\n collectionName: string,\n filter: Filter<Document>,\n options: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.getCollection(collectionName).deleteMany(\n filter,\n options || {},\n )\n }\n\n /**\n * Delete a document on MongoDB.\n */\n async deleteOne(\n collectionName: string,\n filter: Filter<Document>,\n options?: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.getCollection(collectionName).deleteOne(\n filter,\n options || {},\n )\n }\n\n /**\n * The distinct command returns returns a list of distinct values for the given key across a collection.\n */\n async distinct(\n collectionName: string,\n key: any,\n filter: Filter<Document>,\n options?: CommandOperationOptions,\n ): Promise<any> {\n return this.getCollection(collectionName).distinct(\n key,\n filter,\n options || {},\n )\n }\n\n /**\n * Drops an index from this collection.\n */\n async dropCollectionIndex(\n collectionName: string,\n indexName: string,\n options?: CommandOperationOptions,\n ): Promise<Document> {\n return this.getCollection(collectionName).dropIndex(\n indexName,\n options || {},\n )\n }\n\n /**\n * Drops all indexes from the collection.\n */\n async dropCollectionIndexes(collectionName: string): Promise<Document> {\n return this.getCollection(collectionName).dropIndexes()\n }\n\n /**\n * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.\n */\n async findOneAndDelete(\n collectionName: string,\n filter: Filter<Document>,\n options?: FindOneAndDeleteOptions,\n ): Promise<Document | null> {\n return this.getCollection(collectionName).findOneAndDelete(\n filter,\n options || {},\n )\n }\n\n /**\n * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.\n */\n async findOneAndReplace(\n collectionName: string,\n filter: Filter<Document>,\n replacement: Document,\n options?: FindOneAndReplaceOptions,\n ): Promise<Document | null> {\n return this.getCollection(collectionName).findOneAndReplace(\n filter,\n replacement,\n options || {},\n )\n }\n\n /**\n * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.\n */\n async findOneAndUpdate(\n collectionName: string,\n filter: Filter<Document>,\n update: UpdateFilter<Document>,\n options?: FindOneAndUpdateOptions,\n ): Promise<Document | null> {\n return this.getCollection(collectionName).findOneAndUpdate(\n filter,\n update,\n options || {},\n )\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n async collectionIndexes(collectionName: string): Promise<Document> {\n return this.getCollection(collectionName).indexes()\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n async collectionIndexExists(\n collectionName: string,\n indexes: string | string[],\n ): Promise<boolean> {\n return this.getCollection(collectionName).indexExists(indexes)\n }\n\n /**\n * Retrieves this collections index info.\n */\n async collectionIndexInformation(\n collectionName: string,\n options?: IndexInformationOptions,\n ): Promise<any> {\n return this.getCollection(collectionName).indexInformation(\n options || {},\n )\n }\n\n /**\n * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.\n */\n initializeOrderedBulkOp(\n collectionName: string,\n options?: BulkWriteOptions,\n ): OrderedBulkOperation {\n return this.getCollection(collectionName).initializeOrderedBulkOp(\n options,\n )\n }\n\n /**\n * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.\n */\n initializeUnorderedBulkOp(\n collectionName: string,\n options?: BulkWriteOptions,\n ): UnorderedBulkOperation {\n return this.getCollection(collectionName).initializeUnorderedBulkOp(\n options,\n )\n }\n\n /**\n * Inserts an array of documents into MongoDB.\n */\n async insertMany(\n collectionName: string,\n docs: OptionalId<Document>[],\n options?: BulkWriteOptions,\n ): Promise<InsertManyResult> {\n return this.getCollection(collectionName).insertMany(\n docs,\n options || {},\n )\n }\n\n /**\n * Inserts a single document into MongoDB.\n */\n async insertOne(\n collectionName: string,\n doc: OptionalId<Document>,\n options?: InsertOneOptions,\n ): Promise<InsertOneResult> {\n return this.getCollection(collectionName).insertOne(doc, options || {})\n }\n\n /**\n * Returns if the collection is a capped collection.\n */\n async isCapped(collectionName: string): Promise<boolean> {\n return this.getCollection(collectionName).isCapped()\n }\n\n /**\n * Get the list of all indexes information for the collection.\n */\n listCollectionIndexes(\n collectionName: string,\n options?: ListIndexesOptions,\n ): ListIndexesCursor {\n return this.getCollection(collectionName).listIndexes(options)\n }\n\n /**\n * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.\n */\n async rename(\n collectionName: string,\n newName: string,\n options?: RenameOptions,\n ): Promise<Collection<Document>> {\n return this.getCollection(collectionName).rename(newName, options || {})\n }\n\n /**\n * Replace a document on MongoDB.\n */\n async replaceOne(\n collectionName: string,\n filter: Filter<Document>,\n replacement: Document,\n options?: ReplaceOptions,\n ): Promise<Document | UpdateResult> {\n return this.getCollection(collectionName).replaceOne(\n filter,\n replacement,\n options || {},\n )\n }\n\n /**\n * Get all the collection statistics.\n */\n async stats(\n collectionName: string,\n options?: CollStatsOptions,\n ): Promise<CollStats> {\n return this.getCollection(collectionName).stats(options || {})\n }\n\n /**\n * Watching new changes as stream.\n */\n watch(\n collectionName: string,\n pipeline?: Document[],\n options?: ChangeStreamOptions,\n ): ChangeStream {\n return this.getCollection(collectionName).watch(pipeline, options)\n }\n\n /**\n * Update multiple documents on MongoDB.\n */\n async updateMany(\n collectionName: string,\n filter: Filter<Document>,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return this.getCollection(collectionName).updateMany(\n filter,\n update,\n options || {},\n )\n }\n\n /**\n * Update a single document on MongoDB.\n */\n async updateOne(\n collectionName: string,\n filter: Filter<Document>,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return await this.getCollection(collectionName).updateOne(\n filter,\n update,\n options || {},\n )\n }\n\n // -------------------------------------------------------------------------\n // Public Implemented Methods (from QueryRunner)\n // -------------------------------------------------------------------------\n\n /**\n * Removes all collections from the currently connected database.\n * Be careful with using this method and avoid using it in production or migrations\n * (because it can clear all your database).\n */\n async clearDatabase(): Promise<void> {\n await this.databaseConnection\n .db(this.connection.driver.database!)\n .dropDatabase()\n }\n\n /**\n * For MongoDB database we don't create connection, because its single connection already created by a driver.\n */\n async connect(): Promise<any> {}\n\n /**\n * For MongoDB database we don't release connection, because its single connection.\n */\n async release(): Promise<void> {\n // releasing connection are not supported by mongodb driver, so simply don't do anything here\n }\n\n /**\n * Starts transaction.\n */\n async startTransaction(): Promise<void> {\n // transactions are not supported by mongodb driver, so simply don't do anything here\n }\n\n /**\n * Commits transaction.\n */\n async commitTransaction(): Promise<void> {\n // transactions are not supported by mongodb driver, so simply don't do anything here\n }\n\n /**\n * Rollbacks transaction.\n */\n async rollbackTransaction(): Promise<void> {\n // transactions are not supported by mongodb driver, so simply don't do anything here\n }\n\n /**\n * Executes a given SQL query.\n */\n query(query: string, parameters?: any[]): Promise<any> {\n throw new TypeORMError(\n `Executing SQL query is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Returns raw data stream.\n */\n stream(\n query: string,\n parameters?: any[],\n onEnd?: Function,\n onError?: Function,\n ): Promise<ReadStream> {\n throw new TypeORMError(\n `Stream is not supported by MongoDB driver. Use watch instead.`,\n )\n }\n\n /**\n * Insert a new row with given values into the given table.\n * Returns value of inserted object id.\n\n async insert(collectionName: string, keyValues: ObjectLiteral): Promise<any> { // todo: fix any\n const results = await this.databaseConnection\n .collection(collectionName)\n .insertOne(keyValues);\n const generatedMap = this.connection.getMetadata(collectionName).objectIdColumn!.createValueMap(results.insertedId);\n return {\n result: results,\n generatedMap: generatedMap\n };\n }*/\n\n /**\n * Updates rows that match given conditions in the given table.\n\n async update(collectionName: string, valuesMap: ObjectLiteral, conditions: ObjectLiteral): Promise<any> { // todo: fix any\n await this.databaseConnection\n .collection(collectionName)\n .updateOne(conditions, valuesMap);\n }*/\n\n /**\n * Deletes from the given table by a given conditions.\n\n async delete(collectionName: string, conditions: ObjectLiteral|ObjectLiteral[]|string, maybeParameters?: any[]): Promise<any> { // todo: fix any\n if (typeof conditions === \"string\")\n throw new TypeORMError(`String condition is not supported by MongoDB driver.`);\n\n await this.databaseConnection\n .collection(collectionName)\n .deleteOne(conditions);\n }*/\n\n /**\n * Returns all available database names including system databases.\n */\n async getDatabases(): Promise<string[]> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Returns all available schema names including system schemas.\n * If database parameter specified, returns schemas of that database.\n */\n async getSchemas(database?: string): Promise<string[]> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads given table's data from the database.\n */\n async getTable(collectionName: string): Promise<Table | undefined> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads all tables (with given names) from the database and creates a Table from them.\n */\n async getTables(collectionNames: string[]): Promise<Table[]> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads given views's data from the database.\n */\n async getView(collectionName: string): Promise<View | undefined> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads all views (with given names) from the database and creates a Table from them.\n */\n async getViews(collectionNames: string[]): Promise<View[]> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n getReplicationMode(): ReplicationMode {\n return \"master\"\n }\n\n /**\n * Checks if database with the given name exist.\n */\n async hasDatabase(database: string): Promise<boolean> {\n throw new TypeORMError(\n `Check database queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads currently using database\n */\n async getCurrentDatabase(): Promise<undefined> {\n throw new TypeORMError(\n `Check database queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Checks if schema with the given name exist.\n */\n async hasSchema(schema: string): Promise<boolean> {\n throw new TypeORMError(\n `Check schema queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Loads currently using database schema\n */\n async getCurrentSchema(): Promise<undefined> {\n throw new TypeORMError(\n `Check schema queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Checks if table with the given name exist in the database.\n */\n async hasTable(collectionName: string): Promise<boolean> {\n throw new TypeORMError(\n `Check schema queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Checks if column with the given name exist in the given table.\n */\n async hasColumn(\n tableOrName: Table | string,\n columnName: string,\n ): Promise<boolean> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a database if it's not created.\n */\n async createDatabase(database: string): Promise<void> {\n throw new TypeORMError(\n `Database create queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops database.\n */\n async dropDatabase(database: string, ifExist?: boolean): Promise<void> {\n throw new TypeORMError(\n `Database drop queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new table schema.\n */\n async createSchema(\n schemaPath: string,\n ifNotExist?: boolean,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema create queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops table schema.\n */\n async dropSchema(schemaPath: string, ifExist?: boolean): Promise<void> {\n throw new TypeORMError(\n `Schema drop queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new table from the given table and columns inside it.\n */\n async createTable(table: Table): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops the table.\n */\n async dropTable(tableName: Table | string): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new view.\n */\n async createView(view: View): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops the view.\n */\n async dropView(target: View | string): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Renames the given table.\n */\n async renameTable(\n oldTableOrName: Table | string,\n newTableOrName: Table | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new column from the column in the table.\n */\n async addColumn(\n tableOrName: Table | string,\n column: TableColumn,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new columns from the column in the table.\n */\n async addColumns(\n tableOrName: Table | string,\n columns: TableColumn[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Renames column in the given table.\n */\n async renameColumn(\n tableOrName: Table | string,\n oldTableColumnOrName: TableColumn | string,\n newTableColumnOrName: TableColumn | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Changes a column in the table.\n */\n async changeColumn(\n tableOrName: Table | string,\n oldTableColumnOrName: TableColumn | string,\n newColumn: TableColumn,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Changes a column in the table.\n */\n async changeColumns(\n tableOrName: Table | string,\n changedColumns: { newColumn: TableColumn; oldColumn: TableColumn }[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops column in the table.\n */\n async dropColumn(\n tableOrName: Table | string,\n columnOrName: TableColumn | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops the columns in the table.\n */\n async dropColumns(\n tableOrName: Table | string,\n columns: TableColumn[] | string[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new primary key.\n */\n async createPrimaryKey(\n tableOrName: Table | string,\n columnNames: string[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Updates composite primary keys.\n */\n async updatePrimaryKeys(\n tableOrName: Table | string,\n columns: TableColumn[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops a primary key.\n */\n async dropPrimaryKey(tableOrName: Table | string): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new unique constraint.\n */\n async createUniqueConstraint(\n tableOrName: Table | string,\n uniqueConstraint: TableUnique,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new unique constraints.\n */\n async createUniqueConstraints(\n tableOrName: Table | string,\n uniqueConstraints: TableUnique[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops an unique constraint.\n */\n async dropUniqueConstraint(\n tableOrName: Table | string,\n uniqueOrName: TableUnique | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops an unique constraints.\n */\n async dropUniqueConstraints(\n tableOrName: Table | string,\n uniqueConstraints: TableUnique[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new check constraint.\n */\n async createCheckConstraint(\n tableOrName: Table | string,\n checkConstraint: TableCheck,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new check constraints.\n */\n async createCheckConstraints(\n tableOrName: Table | string,\n checkConstraints: TableCheck[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops check constraint.\n */\n async dropCheckConstraint(\n tableOrName: Table | string,\n checkOrName: TableCheck | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops check constraints.\n */\n async dropCheckConstraints(\n tableOrName: Table | string,\n checkConstraints: TableCheck[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new exclusion constraint.\n */\n async createExclusionConstraint(\n tableOrName: Table | string,\n exclusionConstraint: TableExclusion,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new exclusion constraints.\n */\n async createExclusionConstraints(\n tableOrName: Table | string,\n exclusionConstraints: TableExclusion[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops exclusion constraint.\n */\n async dropExclusionConstraint(\n tableOrName: Table | string,\n exclusionOrName: TableExclusion | string,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops exclusion constraints.\n */\n async dropExclusionConstraints(\n tableOrName: Table | string,\n exclusionConstraints: TableExclusion[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new foreign key.\n */\n async createForeignKey(\n tableOrName: Table | string,\n foreignKey: TableForeignKey,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new foreign keys.\n */\n async createForeignKeys(\n tableOrName: Table | string,\n foreignKeys: TableForeignKey[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops a foreign key from the table.\n */\n async dropForeignKey(\n tableOrName: Table | string,\n foreignKey: TableForeignKey,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops a foreign keys from the table.\n */\n async dropForeignKeys(\n tableOrName: Table | string,\n foreignKeys: TableForeignKey[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new index.\n */\n async createIndex(\n tableOrName: Table | string,\n index: TableIndex,\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Creates a new indices\n */\n async createIndices(\n tableOrName: Table | string,\n indices: TableIndex[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops an index from the table.\n */\n async dropIndex(collectionName: string, indexName: string): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops an indices from the table.\n */\n async dropIndices(\n tableOrName: Table | string,\n indices: TableIndex[],\n ): Promise<void> {\n throw new TypeORMError(\n `Schema update queries are not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Drops collection.\n */\n async clearTable(collectionName: string): Promise<void> {\n await this.databaseConnection\n .db(this.connection.driver.database!)\n .dropCollection(collectionName)\n }\n\n /**\n * Enables special query runner mode in which sql queries won't be executed,\n * instead they will be memorized into a special variable inside query runner.\n * You can get memorized sql using getMemorySql() method.\n */\n enableSqlMemory(): void {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Disables special query runner mode in which sql queries won't be executed\n * started by calling enableSqlMemory() method.\n *\n * Previously memorized sql will be flushed.\n */\n disableSqlMemory(): void {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Flushes all memorized sqls.\n */\n clearSqlMemory(): void {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Gets sql stored in the memory. Parameters in the sql are already replaced.\n */\n getMemorySql(): SqlInMemory {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Executes up sql queries.\n */\n async executeMemoryUpSql(): Promise<void> {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n /**\n * Executes down sql queries.\n */\n async executeMemoryDownSql(): Promise<void> {\n throw new TypeORMError(\n `This operation is not supported by MongoDB driver.`,\n )\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets collection from the database with a given name.\n */\n protected getCollection(collectionName: string): Collection<any> {\n return this.databaseConnection\n .db(this.connection.driver.database!)\n .collection(collectionName)\n }\n}\n"],"sourceRoot":"../.."}