typeorm 0.3.27-dev.22b26d1 → 0.3.27-dev.34d8714
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/data-source/BaseDataSourceOptions.d.ts +18 -0
- package/browser/data-source/BaseDataSourceOptions.js.map +1 -1
- package/browser/decorator/columns/Column.d.ts +7 -7
- package/browser/decorator/columns/Column.js +1 -1
- package/browser/decorator/columns/Column.js.map +1 -1
- package/browser/decorator/options/ColumnNumericOptions.d.ts +8 -1
- package/browser/decorator/options/ColumnNumericOptions.js.map +1 -1
- package/browser/decorator/options/ColumnOptions.d.ts +6 -0
- package/browser/decorator/options/ColumnOptions.js.map +1 -1
- package/browser/decorator/options/ColumnUnsignedOptions.d.ts +28 -0
- package/browser/decorator/options/ColumnUnsignedOptions.js +3 -0
- package/browser/decorator/options/ColumnUnsignedOptions.js.map +1 -0
- package/browser/decorator/options/PrimaryGeneratedColumnNumericOptions.d.ts +3 -0
- package/browser/decorator/options/PrimaryGeneratedColumnNumericOptions.js.map +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlDriver.d.ts +15 -19
- package/browser/driver/aurora-mysql/AuroraMysqlDriver.js +7 -27
- package/browser/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.d.ts +7 -7
- package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js +15 -13
- package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
- package/browser/driver/mysql/MysqlDriver.d.ts +23 -19
- package/browser/driver/mysql/MysqlDriver.js +63 -29
- package/browser/driver/mysql/MysqlDriver.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.d.ts +1 -0
- package/browser/driver/mysql/MysqlQueryRunner.js +12 -6
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresDriver.d.ts +1 -0
- package/browser/driver/postgres/PostgresDriver.js +40 -1
- package/browser/driver/postgres/PostgresDriver.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +7 -0
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapDriver.js +6 -0
- package/browser/driver/sap/SapDriver.js.map +1 -1
- package/browser/driver/spanner/SpannerConnectionOptions.d.ts +0 -5
- package/browser/driver/spanner/SpannerConnectionOptions.js.map +1 -1
- package/browser/driver/spanner/SpannerDriver.d.ts +0 -4
- package/browser/driver/spanner/SpannerDriver.js +0 -4
- package/browser/driver/spanner/SpannerDriver.js.map +1 -1
- package/browser/driver/types/ColumnTypes.d.ts +3 -3
- package/browser/driver/types/ColumnTypes.js.map +1 -1
- package/browser/metadata-builder/EntityMetadataBuilder.js +1 -8
- package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/browser/query-builder/QueryBuilder.js +26 -12
- package/browser/query-builder/QueryBuilder.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.js +47 -35
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/util/StringUtils.d.ts +1 -1
- package/browser/util/StringUtils.js +2 -2
- package/browser/util/StringUtils.js.map +1 -1
- package/commands/MigrationCreateCommand.js +7 -0
- package/commands/MigrationCreateCommand.js.map +1 -1
- package/commands/MigrationGenerateCommand.js +7 -0
- package/commands/MigrationGenerateCommand.js.map +1 -1
- package/data-source/BaseDataSourceOptions.d.ts +18 -0
- package/data-source/BaseDataSourceOptions.js.map +1 -1
- package/decorator/columns/Column.d.ts +7 -7
- package/decorator/columns/Column.js +1 -1
- package/decorator/columns/Column.js.map +1 -1
- package/decorator/options/ColumnNumericOptions.d.ts +8 -1
- package/decorator/options/ColumnNumericOptions.js.map +1 -1
- package/decorator/options/ColumnOptions.d.ts +6 -0
- package/decorator/options/ColumnOptions.js.map +1 -1
- package/decorator/options/ColumnUnsignedOptions.d.ts +28 -0
- package/decorator/options/{ColumnWithWidthOptions.js → ColumnUnsignedOptions.js} +1 -1
- package/decorator/options/ColumnUnsignedOptions.js.map +1 -0
- package/decorator/options/PrimaryGeneratedColumnNumericOptions.d.ts +3 -0
- package/decorator/options/PrimaryGeneratedColumnNumericOptions.js.map +1 -1
- package/driver/aurora-mysql/AuroraMysqlDriver.d.ts +15 -19
- package/driver/aurora-mysql/AuroraMysqlDriver.js +7 -27
- package/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
- package/driver/aurora-mysql/AuroraMysqlQueryRunner.d.ts +7 -7
- package/driver/aurora-mysql/AuroraMysqlQueryRunner.js +15 -13
- package/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
- package/driver/mysql/MysqlDriver.d.ts +23 -19
- package/driver/mysql/MysqlDriver.js +63 -29
- package/driver/mysql/MysqlDriver.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.d.ts +1 -0
- package/driver/mysql/MysqlQueryRunner.js +12 -6
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresDriver.d.ts +1 -0
- package/driver/postgres/PostgresDriver.js +40 -1
- package/driver/postgres/PostgresDriver.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +7 -0
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapDriver.js +6 -0
- package/driver/sap/SapDriver.js.map +1 -1
- package/driver/spanner/SpannerConnectionOptions.d.ts +0 -5
- package/driver/spanner/SpannerConnectionOptions.js.map +1 -1
- package/driver/spanner/SpannerDriver.d.ts +0 -4
- package/driver/spanner/SpannerDriver.js +0 -4
- package/driver/spanner/SpannerDriver.js.map +1 -1
- package/driver/types/ColumnTypes.d.ts +3 -3
- package/driver/types/ColumnTypes.js.map +1 -1
- package/metadata-builder/EntityMetadataBuilder.js +1 -8
- package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/QueryBuilder.js +26 -12
- package/query-builder/QueryBuilder.js.map +1 -1
- package/query-builder/SelectQueryBuilder.js +47 -35
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/util/StringUtils.d.ts +1 -1
- package/util/StringUtils.js +2 -2
- package/util/StringUtils.js.map +1 -1
- package/browser/decorator/options/ColumnWithWidthOptions.d.ts +0 -19
- package/browser/decorator/options/ColumnWithWidthOptions.js +0 -3
- package/browser/decorator/options/ColumnWithWidthOptions.js.map +0 -1
- package/decorator/options/ColumnWithWidthOptions.d.ts +0 -19
- package/decorator/options/ColumnWithWidthOptions.js.map +0 -1
|
@@ -54,7 +54,7 @@ interface IHashOptions {
|
|
|
54
54
|
length?: number;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* Returns a
|
|
57
|
+
* Returns a SHA-1 hex digest for internal IDs/aliases (not for cryptographic security)
|
|
58
58
|
*
|
|
59
59
|
* @param input String to be hashed.
|
|
60
60
|
* @param options.length Optionally, shorten the output to desired length.
|
|
@@ -86,7 +86,7 @@ export function shorten(input, options = {}) {
|
|
|
86
86
|
return shortSegments.join(separator);
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
* Returns a
|
|
89
|
+
* Returns a SHA-1 hex digest for internal IDs/aliases (not for cryptographic security)
|
|
90
90
|
*
|
|
91
91
|
* @param input String to be hashed.
|
|
92
92
|
* @param options.length Optionally, shorten the output to desired length.
|
|
@@ -95,7 +95,7 @@ export function hash(input, options = {}) {
|
|
|
95
95
|
const hashFunction = shajs("sha1");
|
|
96
96
|
hashFunction.update(input, "utf8");
|
|
97
97
|
const hashedInput = hashFunction.digest("hex");
|
|
98
|
-
if (options.length) {
|
|
98
|
+
if (options.length && options.length > 0) {
|
|
99
99
|
return hashedInput.slice(0, options.length);
|
|
100
100
|
}
|
|
101
101
|
return hashedInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/util/StringUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,QAAQ,CAAA;AAE1B;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW,E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,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9C,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,WAAW,CAAA;AACtB,CAAC","file":"StringUtils.js","sourcesContent":["import shajs from \"sha.js\"\n\n/**\n * Converts string into camelCase.\n *\n * @see http://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case\n */\nexport function camelCase(str: string, firstCapital: boolean = false): string {\n if (firstCapital) str = \" \" + str\n return str.replace(/^([A-Z])|[\\s-_](\\w)/g, function (match, p1, p2) {\n if (p2) return p2.toUpperCase()\n return p1.toLowerCase()\n })\n}\n\n/**\n * Converts string into snake_case.\n *\n */\nexport function snakeCase(str: string): string {\n return (\n str\n // ABc -> a_bc\n .replace(/([A-Z])([A-Z])([a-z])/g, \"$1_$2$3\")\n // aC -> a_c\n .replace(/([a-z0-9])([A-Z])/g, \"$1_$2\")\n .toLowerCase()\n )\n}\n\n/**\n * Converts string into Title Case.\n *\n * @see http://stackoverflow.com/questions/196972/convert-string-to-title-case-with-javascript\n */\nexport function titleCase(str: string): string {\n return str.replace(\n /\\w\\S*/g,\n (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(),\n )\n}\n\n/**\n * Builds abbreviated string from given string;\n */\nexport function abbreviate(str: string, abbrLettersCount: number = 1): string {\n const words = str\n .replace(/([a-z\\xE0-\\xFF])([A-Z\\xC0\\xDF])/g, \"$1 $2\")\n .split(\" \")\n return words.reduce((res, word) => {\n res += word.substr(0, abbrLettersCount)\n return res\n }, \"\")\n}\n\nexport interface IShortenOptions {\n /** String used to split \"segments\" of the alias/column name */\n separator?: string\n /** Maximum length of any \"segment\" */\n segmentLength?: number\n /** Length of any \"term\" in a \"segment\"; \"OrderItem\" is a segment, \"Order\" and \"Items\" are terms */\n termLength?: number\n}\n\n/**\n * Shorten a given `input`. Useful for RDBMS imposing a limit on the\n * maximum length of aliases and column names in SQL queries.\n *\n * @param input String to be shortened.\n * @param options Default to `4` for segments length, `2` for terms length, `'__'` as a separator.\n *\n * @return Shortened `input`.\n *\n * @example\n * // returns: \"UsShCa__orde__mark__dire\"\n * shorten('UserShoppingCart__order__market__director')\n *\n * // returns: \"cat_wit_ver_lon_nam_pos_wit_ver_lon_nam_pos_wit_ver_lon_nam\"\n * shorten(\n * 'category_with_very_long_name_posts_with_very_long_name_post_with_very_long_name',\n * { separator: '_', segmentLength: 3 }\n * )\n *\n * // equals: UsShCa__orde__mark_market_id\n * `${shorten('UserShoppingCart__order__market')}_market_id`\n */\nexport function shorten(input: string, options: IShortenOptions = {}): string {\n const { segmentLength = 4, separator = \"__\", termLength = 2 } = options\n\n const segments = input.split(separator)\n const shortSegments = segments.reduce((acc: string[], val: string) => {\n // split the given segment into many terms based on an eventual camel cased name\n const segmentTerms = val\n .replace(/([a-z\\xE0-\\xFF])([A-Z\\xC0-\\xDF])/g, \"$1 $2\")\n .split(\" \")\n // \"OrderItemList\" becomes \"OrItLi\", while \"company\" becomes \"comp\"\n const length = segmentTerms.length > 1 ? termLength : segmentLength\n const shortSegment = segmentTerms\n .map((term) => term.substr(0, length))\n .join(\"\")\n\n acc.push(shortSegment)\n return acc\n }, [])\n\n return shortSegments.join(separator)\n}\n\ninterface IHashOptions {\n length?: number\n}\n\n/**\n * Returns a SHA-1 hex digest for internal IDs/aliases (not for cryptographic security)\n *\n * @param input String to be hashed.\n * @param options.length Optionally, shorten the output to desired length.\n */\nexport function hash(input: string, options: IHashOptions = {}): string {\n const hashFunction = shajs(\"sha1\")\n hashFunction.update(input, \"utf8\")\n const hashedInput = hashFunction.digest(\"hex\")\n if (options.length && options.length > 0) {\n return hashedInput.slice(0, options.length)\n }\n return hashedInput\n}\n"],"sourceRoot":".."}
|
|
@@ -86,6 +86,7 @@ export class ${(0, StringUtils_1.camelCase)(name, true)}${timestamp} implements
|
|
|
86
86
|
const exportMethod = esm ? "export" : "module.exports =";
|
|
87
87
|
return `/**
|
|
88
88
|
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
|
|
89
|
+
* @typedef {import('typeorm').QueryRunner} QueryRunner
|
|
89
90
|
*/
|
|
90
91
|
|
|
91
92
|
/**
|
|
@@ -94,9 +95,15 @@ export class ${(0, StringUtils_1.camelCase)(name, true)}${timestamp} implements
|
|
|
94
95
|
*/
|
|
95
96
|
${exportMethod} class ${(0, StringUtils_1.camelCase)(name, true)}${timestamp} {
|
|
96
97
|
|
|
98
|
+
/**
|
|
99
|
+
* @param {QueryRunner} queryRunner
|
|
100
|
+
*/
|
|
97
101
|
async up(queryRunner) {
|
|
98
102
|
}
|
|
99
103
|
|
|
104
|
+
/**
|
|
105
|
+
* @param {QueryRunner} queryRunner
|
|
106
|
+
*/
|
|
100
107
|
async down(queryRunner) {
|
|
101
108
|
}
|
|
102
109
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/MigrationCreateCommand.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,wDAAuB;AAEvB,6DAAyD;AACzD,qDAA+C;AAC/C,iDAA6C;AAE7C;;GAEG;AACH,MAAa,sBAAsB;IAAnC;QACI,YAAO,GAAG,yBAAyB,CAAA;QACnC,aAAQ,GAAG,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/MigrationCreateCommand.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,wDAAuB;AAEvB,6DAAyD;AACzD,qDAA+C;AAC/C,iDAA6C;AAE7C;;GAEG;AACH,MAAa,sBAAsB;IAAnC;QACI,YAAO,GAAG,yBAAyB,CAAA;QACnC,aAAQ,GAAG,+BAA+B,CAAA;IA2H9C,CAAC;IAzHG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,UAAU,CAAC,MAAM,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QA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C,UAAU,CACzB,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAC1C,WAAW,CACd,CAAA;YACD,OAAO,CAAC,GAAG,CACP,aAAa,eAAI,CAAC,IAAI,CAClB,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAC7C,mCAAmC,CACvC,CAAA;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,6BAAa,CAAC,SAAS,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAA;YAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,2BAA2B;IAC3B,4EAA4E;IAE5E;;OAEG;IACO,MAAM,CAAC,WAAW,CAAC,IAAY,EAAE,SAAiB;QACxD,OAAO;;eAEA,IAAA,uBAAS,EACZ,IAAI,EACJ,IAAI,CACP,GAAG,SAAS;;;;;;;;;CASpB,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,qBAAqB,CAClC,IAAY,EACZ,SAAiB,EACjB,GAAY;QAEZ,MAAM,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAA;QACxD,OAAO;;;;;;;;;EASb,YAAY,UAAU,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS;;;;;;;;;;;;;;;CAexD,CAAA;IACG,CAAC;CACJ;AA7HD,wDA6HC","file":"MigrationCreateCommand.js","sourcesContent":["import ansi from \"ansis\"\nimport path from \"path\"\nimport yargs from \"yargs\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { camelCase } from \"../util/StringUtils\"\nimport { CommandUtils } from \"./CommandUtils\"\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(\"esm\", {\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on ESM instead of CommonJS\",\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 args.esm,\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 ${ansi.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 esm: boolean,\n ): string {\n const exportMethod = esm ? \"export\" : \"module.exports =\"\n return `/**\n * @typedef {import('typeorm').MigrationInterface} MigrationInterface\n * @typedef {import('typeorm').QueryRunner} QueryRunner\n */\n\n/**\n * @class\n * @implements {MigrationInterface}\n */\n${exportMethod} class ${camelCase(name, true)}${timestamp} {\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async up(queryRunner) {\n }\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async down(queryRunner) {\n }\n\n}\n`\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -196,6 +196,7 @@ ${downSqls.join(`
|
|
|
196
196
|
const exportMethod = esm ? "export" : "module.exports =";
|
|
197
197
|
return `/**
|
|
198
198
|
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
|
|
199
|
+
* @typedef {import('typeorm').QueryRunner} QueryRunner
|
|
199
200
|
*/
|
|
200
201
|
|
|
201
202
|
/**
|
|
@@ -205,11 +206,17 @@ ${downSqls.join(`
|
|
|
205
206
|
${exportMethod} class ${migrationName} {
|
|
206
207
|
name = '${migrationName}'
|
|
207
208
|
|
|
209
|
+
/**
|
|
210
|
+
* @param {QueryRunner} queryRunner
|
|
211
|
+
*/
|
|
208
212
|
async up(queryRunner) {
|
|
209
213
|
${upSqls.join(`
|
|
210
214
|
`)}
|
|
211
215
|
}
|
|
212
216
|
|
|
217
|
+
/**
|
|
218
|
+
* @param {QueryRunner} queryRunner
|
|
219
|
+
*/
|
|
213
220
|
async down(queryRunner) {
|
|
214
221
|
${downSqls.join(`
|
|
215
222
|
`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/MigrationGenerateCommand.ts"],"names":[],"mappings":";;;;AAAA,uEAA6D;AAC7D,0DAAwB;AACxB,wDAAuB;AACvB,8DAA6B;AAG7B,6DAAyD;AACzD,qDAA+C;AAC/C,iDAA6C;AAE7C;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACI,YA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AAA;QAE5D,MAAM,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAA;QAExD,OAAO;;;;;;;;EAQb,YAAY,UAAU,aAAa;cACvB,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;AAlSD,4DAkSC","file":"MigrationGenerateCommand.js","sourcesContent":["import { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport ansi from \"ansis\"\nimport path from \"path\"\nimport process from \"process\"\nimport yargs from \"yargs\"\nimport { DataSource } from \"../data-source\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { camelCase } from \"../util/StringUtils\"\nimport { CommandUtils } from \"./CommandUtils\"\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(\"esm\", {\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on ESM instead of CommonJS\",\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.replaceAll(\"`\", \"\\\\`\") +\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.replaceAll(\"`\", \"\\\\`\") +\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 ansi.green`No changes in database schema were found`,\n )\n process.exit(0)\n } else {\n console.log(\n ansi.yellow`No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(ansi.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 args.esm,\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 ansi.yellow`Unexpected changes in database schema were found in check mode:\\n\\n${ansi.white(\n fileContent,\n )}`,\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n ansi.green(\n `Migration ${ansi.blue(\n fullPath + extension,\n )} has content:\\n\\n${ansi.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 ansi.green`Migration ${ansi.blue(\n migrationFileName,\n )} has been generated successfully.`,\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 esm: boolean,\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n const exportMethod = esm ? \"export\" : \"module.exports =\"\n\n return `/**\n * @typedef {import('typeorm').MigrationInterface} MigrationInterface\n */\n\n/**\n * @class\n * @implements {MigrationInterface}\n */\n${exportMethod} 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,uEAA6D;AAC7D,0DAAwB;AACxB,wDAAuB;AACvB,8DAA6B;AAG7B,6DAAyD;AACzD,qDAA+C;AAC/C,iDAA6C;AAE7C;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACI,YAAO,GAAG,2BAA2B,CAAA;QACrC,aAAQ,GACJ,gFAAgF,CAAA;IAsSxF,CAAC;IApSG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,UAAU,CAAC,MAAM,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,4B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,CAAC;;;;;;;EAOA,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;AAzSD,4DAySC","file":"MigrationGenerateCommand.js","sourcesContent":["import { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport ansi from \"ansis\"\nimport path from \"path\"\nimport process from \"process\"\nimport yargs from \"yargs\"\nimport { DataSource } from \"../data-source\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { camelCase } from \"../util/StringUtils\"\nimport { CommandUtils } from \"./CommandUtils\"\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(\"esm\", {\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on ESM instead of CommonJS\",\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.replaceAll(\"`\", \"\\\\`\") +\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.replaceAll(\"`\", \"\\\\`\") +\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 ansi.green`No changes in database schema were found`,\n )\n process.exit(0)\n } else {\n console.log(\n ansi.yellow`No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(ansi.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 args.esm,\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 ansi.yellow`Unexpected changes in database schema were found in check mode:\\n\\n${ansi.white(\n fileContent,\n )}`,\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n ansi.green(\n `Migration ${ansi.blue(\n fullPath + extension,\n )} has content:\\n\\n${ansi.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 ansi.green`Migration ${ansi.blue(\n migrationFileName,\n )} has been generated successfully.`,\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 esm: boolean,\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n const exportMethod = esm ? \"export\" : \"module.exports =\"\n\n return `/**\n * @typedef {import('typeorm').MigrationInterface} MigrationInterface\n * @typedef {import('typeorm').QueryRunner} QueryRunner\n */\n\n/**\n * @class\n * @implements {MigrationInterface}\n */\n${exportMethod} class ${migrationName} {\n name = '${migrationName}'\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n /**\n * @param {QueryRunner} queryRunner\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":".."}
|
|
@@ -166,4 +166,22 @@ export interface BaseDataSourceOptions {
|
|
|
166
166
|
* Allows automatic isolation of where clauses
|
|
167
167
|
*/
|
|
168
168
|
readonly isolateWhereStatements?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Controls how null and undefined values are handled in find operations.
|
|
171
|
+
*/
|
|
172
|
+
readonly invalidWhereValuesBehavior?: {
|
|
173
|
+
/**
|
|
174
|
+
* How to handle null values in where conditions.
|
|
175
|
+
* - 'ignore': Skip null properties (default)
|
|
176
|
+
* - 'sql-null': Transform null to SQL NULL
|
|
177
|
+
* - 'throw': Throw an error when null is encountered
|
|
178
|
+
*/
|
|
179
|
+
readonly null?: "ignore" | "sql-null" | "throw";
|
|
180
|
+
/**
|
|
181
|
+
* How to handle undefined values in where conditions.
|
|
182
|
+
* - 'ignore': Skip undefined properties (default)
|
|
183
|
+
* - 'throw': Throw an error when undefined is encountered
|
|
184
|
+
*/
|
|
185
|
+
readonly undefined?: "ignore" | "throw";
|
|
186
|
+
};
|
|
169
187
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data-source/BaseDataSourceOptions.ts"],"names":[],"mappings":"","file":"BaseDataSourceOptions.js","sourcesContent":["import { EntitySchema } from \"../entity-schema/EntitySchema\"\nimport { LoggerOptions } from \"../logger/LoggerOptions\"\nimport { NamingStrategyInterface } from \"../naming-strategy/NamingStrategyInterface\"\nimport { DatabaseType } from \"../driver/types/DatabaseType\"\nimport { Logger } from \"../logger/Logger\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { QueryResultCache } from \"../cache/QueryResultCache\"\nimport { MixedList } from \"../common/MixedList\"\n\n/**\n * BaseDataSourceOptions is set of DataSourceOptions shared by all database types.\n */\nexport interface BaseDataSourceOptions {\n /**\n * Database type. This value is required.\n */\n readonly type: DatabaseType\n\n /**\n * Connection name. If connection name is not given then it will be called \"default\".\n * Different connections must have different names.\n *\n * @deprecated\n */\n readonly name?: string\n\n /**\n * Entities to be loaded for this connection.\n * Accepts both entity classes and directories where from entities need to be loaded.\n * Directories support glob patterns.\n */\n readonly entities?: MixedList<Function | string | EntitySchema>\n\n /**\n * Subscribers to be loaded for this connection.\n * Accepts both subscriber classes and directories where from subscribers need to be loaded.\n * Directories support glob patterns.\n */\n readonly subscribers?: MixedList<Function | string>\n\n /**\n * Migrations to be loaded for this connection.\n * Accepts both migration classes and glob patterns representing migration files.\n */\n readonly migrations?: MixedList<Function | string>\n\n /**\n * Migrations table name, in case of different name from \"migrations\".\n * Accepts single string name.\n */\n readonly migrationsTableName?: string\n\n /**\n * Transaction mode for migrations to run in\n */\n readonly migrationsTransactionMode?: \"all\" | \"none\" | \"each\"\n\n /**\n * Typeorm metadata table name, in case of different name from \"typeorm_metadata\".\n * Accepts single string name.\n */\n readonly metadataTableName?: string\n\n /**\n * Naming strategy to be used to name tables and columns in the database.\n */\n readonly namingStrategy?: NamingStrategyInterface\n\n /**\n * Logging options.\n */\n readonly logging?: LoggerOptions\n\n /**\n * Logger instance used to log queries and events in the ORM.\n */\n readonly logger?:\n | \"advanced-console\"\n | \"simple-console\"\n | \"formatted-console\"\n | \"file\"\n | \"debug\"\n | Logger\n\n /**\n * Maximum number of milliseconds query should be executed before logger log a warning.\n */\n readonly maxQueryExecutionTime?: number\n\n /**\n * Maximum number of clients the pool should contain.\n */\n readonly poolSize?: number\n\n /**\n * Indicates if database schema should be auto created on every application launch.\n * Be careful with this option and don't use this in production - otherwise you can lose production data.\n * This option is useful during debug and development.\n * Alternative to it, you can use CLI and run schema:sync command.\n *\n * Note that for MongoDB database it does not create schema, because MongoDB is schemaless.\n * Instead, it syncs just by creating indices.\n */\n readonly synchronize?: boolean\n\n /**\n * Indicates if migrations should be auto run on every application launch.\n * Alternative to it, you can use CLI and run migrations:run command.\n */\n readonly migrationsRun?: boolean\n\n /**\n * Drops the schema each time connection is being established.\n * Be careful with this option and don't use this in production - otherwise you'll lose all production data.\n * This option is useful during debug and development.\n */\n readonly dropSchema?: boolean\n\n /**\n * Prefix to use on all tables (collections) of this connection in the database.\n */\n readonly entityPrefix?: string\n\n /**\n * When creating new Entity instances, skip all constructors when true.\n */\n readonly entitySkipConstructor?: boolean\n\n /**\n * Extra connection options to be passed to the underlying driver.\n *\n * todo: deprecate this and move all database-specific types into hts own connection options object.\n */\n readonly extra?: any\n\n /**\n * Specifies how relations must be loaded - using \"joins\" or separate queries.\n * If you are loading too much data with nested joins it's better to load relations\n * using separate queries.\n *\n * Default strategy is \"join\", but this default can be changed here.\n * Also, strategy can be set per-query in FindOptions and QueryBuilder.\n */\n readonly relationLoadStrategy?: \"join\" | \"query\"\n\n /**\n * Optionally applied \"typename\" to the model.\n * If set, then each hydrated model will have this property with the target model / entity name inside.\n *\n * (works like a discriminator property).\n */\n readonly typename?: string\n\n /**\n * Holds reference to the baseDirectory where configuration file are expected.\n *\n * @internal\n */\n baseDirectory?: string\n\n /**\n * Allows to setup cache options.\n */\n readonly cache?:\n | boolean\n | {\n /**\n * Type of caching.\n *\n * - \"database\" means cached values will be stored in the separate table in database. This is default value.\n * - \"redis\" means cached values will be stored inside redis. You must provide redis connection options.\n */\n readonly type?:\n | \"database\"\n | \"redis\"\n | \"ioredis\"\n | \"ioredis/cluster\" // todo: add mongodb and other cache providers as well in the future\n\n /**\n * Factory function for custom cache providers that implement QueryResultCache.\n */\n readonly provider?: (connection: DataSource) => QueryResultCache\n\n /**\n * Configurable table name for \"database\" type cache.\n * Default value is \"query-result-cache\"\n */\n readonly tableName?: string\n\n /**\n * Used to provide redis connection options.\n */\n readonly options?: any\n\n /**\n * If set to true then queries (using find methods and QueryBuilder's methods) will always be cached.\n */\n readonly alwaysEnabled?: boolean\n\n /**\n * Time in milliseconds in which cache will expire.\n * This can be setup per-query.\n * Default value is 1000 which is equivalent to 1 second.\n */\n readonly duration?: number\n\n /**\n * Used to specify if cache errors should be ignored, and pass through the call to the Database.\n */\n readonly ignoreErrors?: boolean\n }\n\n /**\n * Allows automatic isolation of where clauses\n */\n readonly isolateWhereStatements?: boolean\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/data-source/BaseDataSourceOptions.ts"],"names":[],"mappings":"","file":"BaseDataSourceOptions.js","sourcesContent":["import { EntitySchema } from \"../entity-schema/EntitySchema\"\nimport { LoggerOptions } from \"../logger/LoggerOptions\"\nimport { NamingStrategyInterface } from \"../naming-strategy/NamingStrategyInterface\"\nimport { DatabaseType } from \"../driver/types/DatabaseType\"\nimport { Logger } from \"../logger/Logger\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { QueryResultCache } from \"../cache/QueryResultCache\"\nimport { MixedList } from \"../common/MixedList\"\n\n/**\n * BaseDataSourceOptions is set of DataSourceOptions shared by all database types.\n */\nexport interface BaseDataSourceOptions {\n /**\n * Database type. This value is required.\n */\n readonly type: DatabaseType\n\n /**\n * Connection name. If connection name is not given then it will be called \"default\".\n * Different connections must have different names.\n *\n * @deprecated\n */\n readonly name?: string\n\n /**\n * Entities to be loaded for this connection.\n * Accepts both entity classes and directories where from entities need to be loaded.\n * Directories support glob patterns.\n */\n readonly entities?: MixedList<Function | string | EntitySchema>\n\n /**\n * Subscribers to be loaded for this connection.\n * Accepts both subscriber classes and directories where from subscribers need to be loaded.\n * Directories support glob patterns.\n */\n readonly subscribers?: MixedList<Function | string>\n\n /**\n * Migrations to be loaded for this connection.\n * Accepts both migration classes and glob patterns representing migration files.\n */\n readonly migrations?: MixedList<Function | string>\n\n /**\n * Migrations table name, in case of different name from \"migrations\".\n * Accepts single string name.\n */\n readonly migrationsTableName?: string\n\n /**\n * Transaction mode for migrations to run in\n */\n readonly migrationsTransactionMode?: \"all\" | \"none\" | \"each\"\n\n /**\n * Typeorm metadata table name, in case of different name from \"typeorm_metadata\".\n * Accepts single string name.\n */\n readonly metadataTableName?: string\n\n /**\n * Naming strategy to be used to name tables and columns in the database.\n */\n readonly namingStrategy?: NamingStrategyInterface\n\n /**\n * Logging options.\n */\n readonly logging?: LoggerOptions\n\n /**\n * Logger instance used to log queries and events in the ORM.\n */\n readonly logger?:\n | \"advanced-console\"\n | \"simple-console\"\n | \"formatted-console\"\n | \"file\"\n | \"debug\"\n | Logger\n\n /**\n * Maximum number of milliseconds query should be executed before logger log a warning.\n */\n readonly maxQueryExecutionTime?: number\n\n /**\n * Maximum number of clients the pool should contain.\n */\n readonly poolSize?: number\n\n /**\n * Indicates if database schema should be auto created on every application launch.\n * Be careful with this option and don't use this in production - otherwise you can lose production data.\n * This option is useful during debug and development.\n * Alternative to it, you can use CLI and run schema:sync command.\n *\n * Note that for MongoDB database it does not create schema, because MongoDB is schemaless.\n * Instead, it syncs just by creating indices.\n */\n readonly synchronize?: boolean\n\n /**\n * Indicates if migrations should be auto run on every application launch.\n * Alternative to it, you can use CLI and run migrations:run command.\n */\n readonly migrationsRun?: boolean\n\n /**\n * Drops the schema each time connection is being established.\n * Be careful with this option and don't use this in production - otherwise you'll lose all production data.\n * This option is useful during debug and development.\n */\n readonly dropSchema?: boolean\n\n /**\n * Prefix to use on all tables (collections) of this connection in the database.\n */\n readonly entityPrefix?: string\n\n /**\n * When creating new Entity instances, skip all constructors when true.\n */\n readonly entitySkipConstructor?: boolean\n\n /**\n * Extra connection options to be passed to the underlying driver.\n *\n * todo: deprecate this and move all database-specific types into hts own connection options object.\n */\n readonly extra?: any\n\n /**\n * Specifies how relations must be loaded - using \"joins\" or separate queries.\n * If you are loading too much data with nested joins it's better to load relations\n * using separate queries.\n *\n * Default strategy is \"join\", but this default can be changed here.\n * Also, strategy can be set per-query in FindOptions and QueryBuilder.\n */\n readonly relationLoadStrategy?: \"join\" | \"query\"\n\n /**\n * Optionally applied \"typename\" to the model.\n * If set, then each hydrated model will have this property with the target model / entity name inside.\n *\n * (works like a discriminator property).\n */\n readonly typename?: string\n\n /**\n * Holds reference to the baseDirectory where configuration file are expected.\n *\n * @internal\n */\n baseDirectory?: string\n\n /**\n * Allows to setup cache options.\n */\n readonly cache?:\n | boolean\n | {\n /**\n * Type of caching.\n *\n * - \"database\" means cached values will be stored in the separate table in database. This is default value.\n * - \"redis\" means cached values will be stored inside redis. You must provide redis connection options.\n */\n readonly type?:\n | \"database\"\n | \"redis\"\n | \"ioredis\"\n | \"ioredis/cluster\" // todo: add mongodb and other cache providers as well in the future\n\n /**\n * Factory function for custom cache providers that implement QueryResultCache.\n */\n readonly provider?: (connection: DataSource) => QueryResultCache\n\n /**\n * Configurable table name for \"database\" type cache.\n * Default value is \"query-result-cache\"\n */\n readonly tableName?: string\n\n /**\n * Used to provide redis connection options.\n */\n readonly options?: any\n\n /**\n * If set to true then queries (using find methods and QueryBuilder's methods) will always be cached.\n */\n readonly alwaysEnabled?: boolean\n\n /**\n * Time in milliseconds in which cache will expire.\n * This can be setup per-query.\n * Default value is 1000 which is equivalent to 1 second.\n */\n readonly duration?: number\n\n /**\n * Used to specify if cache errors should be ignored, and pass through the call to the Database.\n */\n readonly ignoreErrors?: boolean\n }\n\n /**\n * Allows automatic isolation of where clauses\n */\n readonly isolateWhereStatements?: boolean\n\n /**\n * Controls how null and undefined values are handled in find operations.\n */\n readonly invalidWhereValuesBehavior?: {\n /**\n * How to handle null values in where conditions.\n * - 'ignore': Skip null properties (default)\n * - 'sql-null': Transform null to SQL NULL\n * - 'throw': Throw an error when null is encountered\n */\n readonly null?: \"ignore\" | \"sql-null\" | \"throw\"\n\n /**\n * How to handle undefined values in where conditions.\n * - 'ignore': Skip undefined properties (default)\n * - 'throw': Throw an error when undefined is encountered\n */\n readonly undefined?: \"ignore\" | \"throw\"\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { SimpleColumnType, SpatialColumnType, WithLengthColumnType, WithPrecisionColumnType
|
|
1
|
+
import { SimpleColumnType, SpatialColumnType, UnsignedColumnType, WithLengthColumnType, WithPrecisionColumnType } from "../../driver/types/ColumnTypes";
|
|
2
2
|
import { ColumnCommonOptions } from "../options/ColumnCommonOptions";
|
|
3
|
-
import { SpatialColumnOptions } from "../options/SpatialColumnOptions";
|
|
4
|
-
import { ColumnWithLengthOptions } from "../options/ColumnWithLengthOptions";
|
|
5
|
-
import { ColumnNumericOptions } from "../options/ColumnNumericOptions";
|
|
6
|
-
import { ColumnEnumOptions } from "../options/ColumnEnumOptions";
|
|
7
3
|
import { ColumnEmbeddedOptions } from "../options/ColumnEmbeddedOptions";
|
|
4
|
+
import { ColumnEnumOptions } from "../options/ColumnEnumOptions";
|
|
8
5
|
import { ColumnHstoreOptions } from "../options/ColumnHstoreOptions";
|
|
9
|
-
import {
|
|
6
|
+
import { ColumnNumericOptions } from "../options/ColumnNumericOptions";
|
|
10
7
|
import { ColumnOptions } from "../options/ColumnOptions";
|
|
8
|
+
import { ColumnUnsignedOptions } from "../options/ColumnUnsignedOptions";
|
|
9
|
+
import { ColumnWithLengthOptions } from "../options/ColumnWithLengthOptions";
|
|
10
|
+
import { SpatialColumnOptions } from "../options/SpatialColumnOptions";
|
|
11
11
|
/**
|
|
12
12
|
* Column decorator is used to mark a specific class property as a table column. Only properties decorated with this
|
|
13
13
|
* decorator will be persisted to the database when entity be saved.
|
|
@@ -37,7 +37,7 @@ export declare function Column(type: WithLengthColumnType, options?: ColumnCommo
|
|
|
37
37
|
* Column decorator is used to mark a specific class property as a table column.
|
|
38
38
|
* Only properties decorated with this decorator will be persisted to the database when entity be saved.
|
|
39
39
|
*/
|
|
40
|
-
export declare function Column(type:
|
|
40
|
+
export declare function Column(type: UnsignedColumnType, options?: ColumnCommonOptions & ColumnUnsignedOptions): PropertyDecorator;
|
|
41
41
|
/**
|
|
42
42
|
* Column decorator is used to mark a specific class property as a table column.
|
|
43
43
|
* Only properties decorated with this decorator will be persisted to the database when entity be saved.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Column = Column;
|
|
4
|
-
const globals_1 = require("../../globals");
|
|
5
4
|
const ColumnTypeUndefinedError_1 = require("../../error/ColumnTypeUndefinedError");
|
|
5
|
+
const globals_1 = require("../../globals");
|
|
6
6
|
/**
|
|
7
7
|
* Column decorator is used to mark a specific class property as a table column.
|
|
8
8
|
* Only properties decorated with this decorator will be persisted to the database when entity be saved.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/columns/Column.ts"],"names":[],"mappings":";;AAqIA,wBAsFC;AA3ND,2CAAsD;AAiBtD,mFAA+E;AAgH/E;;;GAGG;AACH,SAAgB,MAAM,CAClB,aAG6C,EAC7C,OAA+C;IAE/C,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,uBAAuB;QACvB,IAAI,IAA4B,CAAA;QAChC,IACI,OAAO,aAAa,KAAK,QAAQ;YACjC,OAAO,aAAa,KAAK,UAAU,EACrC,CAAC;YACC,IAAI,GAAe,aA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zF,IAAI,CAAC,OAAO,CAAC,IAAI;gBACb,MAAM,IAAI,mDAAwB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;YAE5D,gBAAgB;YAChB,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI;gBACvB,IAAA,gCAAsB,GAAE,CAAC,OAAO,CAAC,IAAI,CAAC;oBAClC,MAAM,EAAE,MAAM,CAAC,WAAW;oBAC1B,OAAO,EAAE,CAAC,YAAY,CAAC;iBAC1B,CAAC,CAAA;YAEN,IAAA,gCAAsB,GAAE,CAAC,OAAO,CAAC,IAAI,CAAC;gBAClC,MAAM,EAAE,MAAM,CAAC,WAAW;gBAC1B,YAAY,EAAE,YAAY;gBAC1B,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,OAAO;aACG,CAAC,CAAA;YAExB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;gBACpB,IAAA,gCAAsB,GAAE,CAAC,WAAW,CAAC,IAAI,CAAC;oBACtC,MAAM,EAAE,MAAM,CAAC,WAAW;oBAC1B,YAAY,EAAE,YAAY;oBAC1B,QAAQ,EACJ,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ;wBACjC,CAAC,CAAC,OAAO,CAAC,SAAS;wBACnB,CAAC,CAAC,WAAW;iBACC,CAAC,CAAA;YAC/B,CAAC;QACL,CAAC;IACL,CAAC,CAAA;AACL,CAAC","file":"Column.js","sourcesContent":["import { getMetadataArgsStorage } from \"../../globals\"\nimport {\n ColumnType,\n SimpleColumnType,\n SpatialColumnType,\n WithLengthColumnType,\n WithPrecisionColumnType,\n WithWidthColumnType,\n} from \"../../driver/types/ColumnTypes\"\nimport { ColumnMetadataArgs } from \"../../metadata-args/ColumnMetadataArgs\"\nimport { ColumnCommonOptions } from \"../options/ColumnCommonOptions\"\nimport { SpatialColumnOptions } from \"../options/SpatialColumnOptions\"\nimport { ColumnWithLengthOptions } from \"../options/ColumnWithLengthOptions\"\nimport { ColumnNumericOptions } from \"../options/ColumnNumericOptions\"\nimport { ColumnEnumOptions } from \"../options/ColumnEnumOptions\"\nimport { ColumnEmbeddedOptions } from \"../options/ColumnEmbeddedOptions\"\nimport { EmbeddedMetadataArgs } from \"../../metadata-args/EmbeddedMetadataArgs\"\nimport { ColumnTypeUndefinedError } from \"../../error/ColumnTypeUndefinedError\"\nimport { ColumnHstoreOptions } from \"../options/ColumnHstoreOptions\"\nimport { ColumnWithWidthOptions } from \"../options/ColumnWithWidthOptions\"\nimport { GeneratedMetadataArgs } from \"../../metadata-args/GeneratedMetadataArgs\"\nimport { ColumnOptions } from \"../options/ColumnOptions\"\n\n/**\n * Column decorator is used to mark a specific class property as a table column. Only properties decorated with this\n * decorator will be persisted to the database when entity be saved.\n */\nexport function Column(): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(options: ColumnOptions): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: SimpleColumnType,\n options?: ColumnCommonOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: SpatialColumnType,\n options?: ColumnCommonOptions & SpatialColumnOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: WithLengthColumnType,\n options?: ColumnCommonOptions & ColumnWithLengthOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: WithWidthColumnType,\n options?: ColumnCommonOptions & ColumnWithWidthOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: WithPrecisionColumnType,\n options?: ColumnCommonOptions & ColumnNumericOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: \"enum\",\n options?: ColumnCommonOptions & ColumnEnumOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: \"simple-enum\",\n options?: ColumnCommonOptions & ColumnEnumOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: \"set\",\n options?: ColumnCommonOptions & ColumnEnumOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: \"hstore\",\n options?: ColumnCommonOptions & ColumnHstoreOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n *\n * Property in entity can be marked as Embedded, and on persist all columns from the embedded are mapped to the\n * single table of the entity where Embedded is used. And on hydration all columns which supposed to be in the\n * embedded will be mapped to it from the single table.\n */\nexport function Column(\n type: (type?: any) => Function,\n options?: ColumnEmbeddedOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n typeOrOptions?:\n | ((type?: any) => Function)\n | ColumnType\n | (ColumnOptions & ColumnEmbeddedOptions),\n options?: ColumnOptions & ColumnEmbeddedOptions,\n): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n // normalize parameters\n let type: ColumnType | undefined\n if (\n typeof typeOrOptions === \"string\" ||\n typeof typeOrOptions === \"function\"\n ) {\n type = <ColumnType>typeOrOptions\n } else if (typeOrOptions) {\n options = <ColumnOptions>typeOrOptions\n type = typeOrOptions.type\n }\n if (!options) options = {} as ColumnOptions\n\n // if type is not given explicitly then try to guess it\n const reflectMetadataType =\n Reflect && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(\n \"design:type\",\n object,\n propertyName,\n )\n : undefined\n if (!type && reflectMetadataType)\n // if type is not given explicitly then try to guess it\n type = reflectMetadataType\n\n // check if there is no type in column options then set type from first function argument, or guessed one\n if (!options.type && type) options.type = type\n\n // specify HSTORE type if column is HSTORE\n if (options.type === \"hstore\" && !options.hstoreType)\n options.hstoreType =\n reflectMetadataType === Object ? \"object\" : \"string\"\n\n if (typeof typeOrOptions === \"function\") {\n // register an embedded\n getMetadataArgsStorage().embeddeds.push({\n target: object.constructor,\n propertyName: propertyName,\n isArray:\n reflectMetadataType === Array || options.array === true,\n prefix:\n options.prefix !== undefined ? options.prefix : undefined,\n type: typeOrOptions as (type?: any) => Function,\n } as EmbeddedMetadataArgs)\n } else {\n // register a regular column\n\n // if we still don't have a type then we need to give error to user that type is required\n if (!options.type)\n throw new ColumnTypeUndefinedError(object, propertyName)\n\n // create unique\n if (options.unique === true)\n getMetadataArgsStorage().uniques.push({\n target: object.constructor,\n columns: [propertyName],\n })\n\n getMetadataArgsStorage().columns.push({\n target: object.constructor,\n propertyName: propertyName,\n mode: \"regular\",\n options: options,\n } as ColumnMetadataArgs)\n\n if (options.generated) {\n getMetadataArgsStorage().generations.push({\n target: object.constructor,\n propertyName: propertyName,\n strategy:\n typeof options.generated === \"string\"\n ? options.generated\n : \"increment\",\n } as GeneratedMetadataArgs)\n }\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/columns/Column.ts"],"names":[],"mappings":";;AAqIA,wBAsFC;AAnND,mFAA+E;AAC/E,2CAAsD;AAwHtD;;;GAGG;AACH,SAAgB,MAAM,CAClB,aAG6C,EAC7C,OAA+C;IAE/C,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,uBAAu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C,CAAC,CAAC,SAAS;gBAC7D,IAAI,EAAE,aAAyC;aAC1B,CAAC,CAAA;QAC9B,CAAC;aAAM,CAAC;YACJ,4BAA4B;YAE5B,yFAAyF;YACzF,IAAI,CAAC,OAAO,CAAC,IAAI;gBACb,MAAM,IAAI,mDAAwB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;YAE5D,gBAAgB;YAChB,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI;gBACvB,IAAA,gCAAsB,GAAE,CAAC,OAAO,CAAC,IAAI,CAAC;oBAClC,MAAM,EAAE,MAAM,CAAC,WAAW;oBAC1B,OAAO,EAAE,CAAC,YAAY,CAAC;iBAC1B,CAAC,CAAA;YAEN,IAAA,gCAAsB,GAAE,CAAC,OAAO,CAAC,IAAI,CAAC;gBAClC,MAAM,EAAE,MAAM,CAAC,WAAW;gBAC1B,YAAY,EAAE,YAAY;gBAC1B,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,OAAO;aACG,CAAC,CAAA;YAExB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;gBACpB,IAAA,gCAAsB,GAAE,CAAC,WAAW,CAAC,IAAI,CAAC;oBACtC,MAAM,EAAE,MAAM,CAAC,WAAW;oBAC1B,YAAY,EAAE,YAAY;oBAC1B,QAAQ,EACJ,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ;wBACjC,CAAC,CAAC,OAAO,CAAC,SAAS;wBACnB,CAAC,CAAC,WAAW;iBACC,CAAC,CAAA;YAC/B,CAAC;QACL,CAAC;IACL,CAAC,CAAA;AACL,CAAC","file":"Column.js","sourcesContent":["import {\n ColumnType,\n SimpleColumnType,\n SpatialColumnType,\n UnsignedColumnType,\n WithLengthColumnType,\n WithPrecisionColumnType,\n} from \"../../driver/types/ColumnTypes\"\nimport { ColumnTypeUndefinedError } from \"../../error/ColumnTypeUndefinedError\"\nimport { getMetadataArgsStorage } from \"../../globals\"\nimport { ColumnMetadataArgs } from \"../../metadata-args/ColumnMetadataArgs\"\nimport { EmbeddedMetadataArgs } from \"../../metadata-args/EmbeddedMetadataArgs\"\nimport { GeneratedMetadataArgs } from \"../../metadata-args/GeneratedMetadataArgs\"\nimport { ColumnCommonOptions } from \"../options/ColumnCommonOptions\"\nimport { ColumnEmbeddedOptions } from \"../options/ColumnEmbeddedOptions\"\nimport { ColumnEnumOptions } from \"../options/ColumnEnumOptions\"\nimport { ColumnHstoreOptions } from \"../options/ColumnHstoreOptions\"\nimport { ColumnNumericOptions } from \"../options/ColumnNumericOptions\"\nimport { ColumnOptions } from \"../options/ColumnOptions\"\nimport { ColumnUnsignedOptions } from \"../options/ColumnUnsignedOptions\"\nimport { ColumnWithLengthOptions } from \"../options/ColumnWithLengthOptions\"\nimport { SpatialColumnOptions } from \"../options/SpatialColumnOptions\"\n\n/**\n * Column decorator is used to mark a specific class property as a table column. Only properties decorated with this\n * decorator will be persisted to the database when entity be saved.\n */\nexport function Column(): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(options: ColumnOptions): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: SimpleColumnType,\n options?: ColumnCommonOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: SpatialColumnType,\n options?: ColumnCommonOptions & SpatialColumnOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: WithLengthColumnType,\n options?: ColumnCommonOptions & ColumnWithLengthOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: UnsignedColumnType,\n options?: ColumnCommonOptions & ColumnUnsignedOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: WithPrecisionColumnType,\n options?: ColumnCommonOptions & ColumnNumericOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: \"enum\",\n options?: ColumnCommonOptions & ColumnEnumOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: \"simple-enum\",\n options?: ColumnCommonOptions & ColumnEnumOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: \"set\",\n options?: ColumnCommonOptions & ColumnEnumOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n type: \"hstore\",\n options?: ColumnCommonOptions & ColumnHstoreOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n *\n * Property in entity can be marked as Embedded, and on persist all columns from the embedded are mapped to the\n * single table of the entity where Embedded is used. And on hydration all columns which supposed to be in the\n * embedded will be mapped to it from the single table.\n */\nexport function Column(\n type: (type?: any) => Function,\n options?: ColumnEmbeddedOptions,\n): PropertyDecorator\n\n/**\n * Column decorator is used to mark a specific class property as a table column.\n * Only properties decorated with this decorator will be persisted to the database when entity be saved.\n */\nexport function Column(\n typeOrOptions?:\n | ((type?: any) => Function)\n | ColumnType\n | (ColumnOptions & ColumnEmbeddedOptions),\n options?: ColumnOptions & ColumnEmbeddedOptions,\n): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n // normalize parameters\n let type: ColumnType | undefined\n if (\n typeof typeOrOptions === \"string\" ||\n typeof typeOrOptions === \"function\"\n ) {\n type = <ColumnType>typeOrOptions\n } else if (typeOrOptions) {\n options = <ColumnOptions>typeOrOptions\n type = typeOrOptions.type\n }\n if (!options) options = {} as ColumnOptions\n\n // if type is not given explicitly then try to guess it\n const reflectMetadataType =\n Reflect && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(\n \"design:type\",\n object,\n propertyName,\n )\n : undefined\n if (!type && reflectMetadataType)\n // if type is not given explicitly then try to guess it\n type = reflectMetadataType\n\n // check if there is no type in column options then set type from first function argument, or guessed one\n if (!options.type && type) options.type = type\n\n // specify HSTORE type if column is HSTORE\n if (options.type === \"hstore\" && !options.hstoreType)\n options.hstoreType =\n reflectMetadataType === Object ? \"object\" : \"string\"\n\n if (typeof typeOrOptions === \"function\") {\n // register an embedded\n getMetadataArgsStorage().embeddeds.push({\n target: object.constructor,\n propertyName: propertyName,\n isArray:\n reflectMetadataType === Array || options.array === true,\n prefix:\n options.prefix !== undefined ? options.prefix : undefined,\n type: typeOrOptions as (type?: any) => Function,\n } as EmbeddedMetadataArgs)\n } else {\n // register a regular column\n\n // if we still don't have a type then we need to give error to user that type is required\n if (!options.type)\n throw new ColumnTypeUndefinedError(object, propertyName)\n\n // create unique\n if (options.unique === true)\n getMetadataArgsStorage().uniques.push({\n target: object.constructor,\n columns: [propertyName],\n })\n\n getMetadataArgsStorage().columns.push({\n target: object.constructor,\n propertyName: propertyName,\n mode: \"regular\",\n options: options,\n } as ColumnMetadataArgs)\n\n if (options.generated) {\n getMetadataArgsStorage().generations.push({\n target: object.constructor,\n propertyName: propertyName,\n strategy:\n typeof options.generated === \"string\"\n ? options.generated\n : \"increment\",\n } as GeneratedMetadataArgs)\n }\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
@@ -14,11 +14,18 @@ export interface ColumnNumericOptions {
|
|
|
14
14
|
scale?: number;
|
|
15
15
|
/**
|
|
16
16
|
* Puts ZEROFILL attribute on to numeric column. Works only for MySQL.
|
|
17
|
-
* If you specify ZEROFILL for a numeric column, MySQL automatically adds
|
|
17
|
+
* If you specify ZEROFILL for a numeric column, MySQL automatically adds
|
|
18
|
+
* the UNSIGNED attribute to the column
|
|
19
|
+
* @deprecated MySQL deprecated and removed the ZEROFILL attribute. This
|
|
20
|
+
* will also be removed from TypeORM in an upcoming version. Use a character
|
|
21
|
+
* column and the `LPAD` function as suggested by MySQL or handle the
|
|
22
|
+
* formatting in the application layer.
|
|
18
23
|
*/
|
|
19
24
|
zerofill?: boolean;
|
|
20
25
|
/**
|
|
21
26
|
* Puts UNSIGNED attribute on to numeric column. Works only for MySQL.
|
|
27
|
+
* @deprecated MySQL deprecated the UNSIGNED attribute for non-integer
|
|
28
|
+
* numeric types. This will also be removed from TypeORM in an upcoming version.
|
|
22
29
|
*/
|
|
23
30
|
unsigned?: boolean;
|
|
24
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/options/ColumnNumericOptions.ts"],"names":[],"mappings":"","file":"ColumnNumericOptions.js","sourcesContent":["/**\n * Options for numeric column types where user can specify scale and precision.\n */\nexport interface ColumnNumericOptions {\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/options/ColumnNumericOptions.ts"],"names":[],"mappings":"","file":"ColumnNumericOptions.js","sourcesContent":["/**\n * Options for numeric column types where user can specify scale and precision.\n */\nexport interface ColumnNumericOptions {\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds\n * the UNSIGNED attribute to the column\n * @deprecated MySQL deprecated and removed the ZEROFILL attribute. This\n * will also be removed from TypeORM in an upcoming version. Use a character\n * column and the `LPAD` function as suggested by MySQL or handle the\n * formatting in the application layer.\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n * @deprecated MySQL deprecated the UNSIGNED attribute for non-integer\n * numeric types. This will also be removed from TypeORM in an upcoming version.\n */\n unsigned?: boolean\n}\n"],"sourceRoot":"../.."}
|
|
@@ -21,6 +21,9 @@ export interface ColumnOptions extends ColumnCommonOptions {
|
|
|
21
21
|
/**
|
|
22
22
|
* Column type's display width. Used only on some column types in MySQL.
|
|
23
23
|
* For example, INT(4) specifies an INT with a display width of four digits.
|
|
24
|
+
* @deprecated No longer supported in newer MySQL versions, will be removed
|
|
25
|
+
* from TypeORM in an upcoming version. Use a character column and the
|
|
26
|
+
* `LPAD` function as suggested by MySQL
|
|
24
27
|
*/
|
|
25
28
|
width?: number;
|
|
26
29
|
/**
|
|
@@ -88,6 +91,9 @@ export interface ColumnOptions extends ColumnCommonOptions {
|
|
|
88
91
|
/**
|
|
89
92
|
* Puts ZEROFILL attribute on to numeric column. Works only for MySQL.
|
|
90
93
|
* If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to this column
|
|
94
|
+
* @deprecated No longer supported in newer MySQL versions, will be removed
|
|
95
|
+
* from TypeORM in an upcoming version. Use a character column and the
|
|
96
|
+
* `LPAD` function as suggested by MySQL
|
|
91
97
|
*/
|
|
92
98
|
zerofill?: boolean;
|
|
93
99
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/options/ColumnOptions.ts"],"names":[],"mappings":"","file":"ColumnOptions.js","sourcesContent":["import { ColumnType } from \"../../driver/types/ColumnTypes\"\nimport { ValueTransformer } from \"./ValueTransformer\"\nimport { ColumnCommonOptions } from \"./ColumnCommonOptions\"\n\n/**\n * Describes all column's options.\n */\nexport interface ColumnOptions extends ColumnCommonOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: ColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column type's length. Used only on some column types.\n * For example type = \"string\" and length = \"100\" means that ORM will create a column with type varchar(100).\n */\n length?: string | number\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n */\n width?: number\n\n /**\n * Indicates if column's value can be set to NULL.\n * Default value is \"false\".\n */\n nullable?: boolean\n\n /**\n * Indicates if column value is not updated by \"save\" operation.\n * It means you'll be able to write this value only when you first time insert the object.\n * Default value is \"false\".\n *\n * @deprecated Please use the `update` option instead. Careful, it takes\n * the opposite value to readonly.\n *\n */\n readonly?: boolean\n\n /**\n * Indicates if column value is updated by \"save\" operation.\n * If false, you'll be able to write this value only when you first time insert the object.\n * Default value is \"true\".\n */\n update?: boolean\n\n /**\n * Indicates if column is always selected by QueryBuilder and find operations.\n * Default value is \"true\".\n */\n select?: boolean\n\n /**\n * Indicates if column is inserted by default.\n * Default value is \"true\".\n */\n insert?: boolean\n\n /**\n * Default database value.\n */\n default?: any\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string\n\n /**\n * Indicates if this column is a primary key.\n * Same can be achieved when @PrimaryColumn decorator is used.\n */\n primary?: boolean\n\n /**\n * Specifies if column's value must be unique or not.\n */\n unique?: boolean\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number | null\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to this column\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n\n /**\n * Defines a column character set.\n * Not supported by all database types.\n */\n charset?: string\n\n /**\n * Defines a column collation.\n */\n collation?: string\n\n /**\n * Array of possible enumerated values.\n */\n enum?: (string | number)[] | Object\n\n /**\n * Exact name of enum\n */\n enumName?: string\n\n /**\n * If this column is primary key then this specifies the name for it.\n */\n primaryKeyConstraintName?: string\n\n /**\n * If this column is foreign key then this specifies the name for it.\n */\n foreignKeyConstraintName?: string\n\n /**\n * Generated column expression.\n */\n asExpression?: string\n\n /**\n * Generated column type.\n */\n generatedType?: \"VIRTUAL\" | \"STORED\"\n\n /**\n * Identity column type. Supports only in Postgres 10+.\n */\n generatedIdentity?: \"ALWAYS\" | \"BY DEFAULT\"\n\n /**\n * Return type of HSTORE column.\n * Returns value as string or as object.\n */\n hstoreType?: \"object\" | \"string\"\n\n /**\n * Indicates if this column is an array.\n * Can be simply set to true or array length can be specified.\n * Supported only by postgres.\n */\n array?: boolean\n\n /**\n * Specifies a value transformer that is to be used to (un)marshal\n * this column when reading or writing to the database.\n */\n transformer?: ValueTransformer | ValueTransformer[]\n\n /**\n * Spatial Feature Type (Geometry, Point, Polygon, etc.)\n */\n spatialFeatureType?: string\n\n /**\n * SRID (Spatial Reference ID (EPSG code))\n */\n srid?: number\n\n /**\n * Query to be used to populate the column data. This query is used when generating the relational db script.\n * The query function is called with the current entities alias either defined by the Entity Decorator or automatically\n * @See https://typeorm.io/decorator-reference#virtualcolumn for more details.\n */\n query?: (alias: string) => string\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/options/ColumnOptions.ts"],"names":[],"mappings":"","file":"ColumnOptions.js","sourcesContent":["import { ColumnType } from \"../../driver/types/ColumnTypes\"\nimport { ValueTransformer } from \"./ValueTransformer\"\nimport { ColumnCommonOptions } from \"./ColumnCommonOptions\"\n\n/**\n * Describes all column's options.\n */\nexport interface ColumnOptions extends ColumnCommonOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: ColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column type's length. Used only on some column types.\n * For example type = \"string\" and length = \"100\" means that ORM will create a column with type varchar(100).\n */\n length?: string | number\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n * @deprecated No longer supported in newer MySQL versions, will be removed\n * from TypeORM in an upcoming version. Use a character column and the\n * `LPAD` function as suggested by MySQL\n */\n width?: number\n\n /**\n * Indicates if column's value can be set to NULL.\n * Default value is \"false\".\n */\n nullable?: boolean\n\n /**\n * Indicates if column value is not updated by \"save\" operation.\n * It means you'll be able to write this value only when you first time insert the object.\n * Default value is \"false\".\n *\n * @deprecated Please use the `update` option instead. Careful, it takes\n * the opposite value to readonly.\n *\n */\n readonly?: boolean\n\n /**\n * Indicates if column value is updated by \"save\" operation.\n * If false, you'll be able to write this value only when you first time insert the object.\n * Default value is \"true\".\n */\n update?: boolean\n\n /**\n * Indicates if column is always selected by QueryBuilder and find operations.\n * Default value is \"true\".\n */\n select?: boolean\n\n /**\n * Indicates if column is inserted by default.\n * Default value is \"true\".\n */\n insert?: boolean\n\n /**\n * Default database value.\n */\n default?: any\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string\n\n /**\n * Indicates if this column is a primary key.\n * Same can be achieved when @PrimaryColumn decorator is used.\n */\n primary?: boolean\n\n /**\n * Specifies if column's value must be unique or not.\n */\n unique?: boolean\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number | null\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to this column\n * @deprecated No longer supported in newer MySQL versions, will be removed\n * from TypeORM in an upcoming version. Use a character column and the\n * `LPAD` function as suggested by MySQL\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n\n /**\n * Defines a column character set.\n * Not supported by all database types.\n */\n charset?: string\n\n /**\n * Defines a column collation.\n */\n collation?: string\n\n /**\n * Array of possible enumerated values.\n */\n enum?: (string | number)[] | Object\n\n /**\n * Exact name of enum\n */\n enumName?: string\n\n /**\n * If this column is primary key then this specifies the name for it.\n */\n primaryKeyConstraintName?: string\n\n /**\n * If this column is foreign key then this specifies the name for it.\n */\n foreignKeyConstraintName?: string\n\n /**\n * Generated column expression.\n */\n asExpression?: string\n\n /**\n * Generated column type.\n */\n generatedType?: \"VIRTUAL\" | \"STORED\"\n\n /**\n * Identity column type. Supports only in Postgres 10+.\n */\n generatedIdentity?: \"ALWAYS\" | \"BY DEFAULT\"\n\n /**\n * Return type of HSTORE column.\n * Returns value as string or as object.\n */\n hstoreType?: \"object\" | \"string\"\n\n /**\n * Indicates if this column is an array.\n * Can be simply set to true or array length can be specified.\n * Supported only by postgres.\n */\n array?: boolean\n\n /**\n * Specifies a value transformer that is to be used to (un)marshal\n * this column when reading or writing to the database.\n */\n transformer?: ValueTransformer | ValueTransformer[]\n\n /**\n * Spatial Feature Type (Geometry, Point, Polygon, etc.)\n */\n spatialFeatureType?: string\n\n /**\n * SRID (Spatial Reference ID (EPSG code))\n */\n srid?: number\n\n /**\n * Query to be used to populate the column data. This query is used when generating the relational db script.\n * The query function is called with the current entities alias either defined by the Entity Decorator or automatically\n * @See https://typeorm.io/decorator-reference#virtualcolumn for more details.\n */\n query?: (alias: string) => string\n}\n"],"sourceRoot":"../.."}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for columns that can define a length of the column type.
|
|
3
|
+
*/
|
|
4
|
+
export interface ColumnUnsignedOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Column type's display width. Used only on some column types in MySQL.
|
|
7
|
+
* For example, INT(4) specifies an INT with a display width of four digits.
|
|
8
|
+
* @deprecated MySQL deprecated and removed display width for integer types,
|
|
9
|
+
* TypeORM will also remove it in an upcoming version. Use a character
|
|
10
|
+
* column and the `LPAD` function as suggested by MySQL or handle the
|
|
11
|
+
* formatting in the application layer.
|
|
12
|
+
*/
|
|
13
|
+
width?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Puts ZEROFILL attribute on to numeric column. Works only for MySQL.
|
|
16
|
+
* If you specify ZEROFILL for a numeric column, MySQL automatically adds
|
|
17
|
+
* the UNSIGNED attribute to this column
|
|
18
|
+
* @deprecated MySQL deprecated and removed the zerofill attribute. This
|
|
19
|
+
* will also be removed from TypeORM in an upcoming version. Use a character
|
|
20
|
+
* column and the `LPAD` function as suggested by MySQL or handle the
|
|
21
|
+
* formatting in the application layer.
|
|
22
|
+
*/
|
|
23
|
+
zerofill?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Puts UNSIGNED attribute on to numeric column. Works only for MySQL.
|
|
26
|
+
*/
|
|
27
|
+
unsigned?: boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/options/ColumnUnsignedOptions.ts"],"names":[],"mappings":"","file":"ColumnUnsignedOptions.js","sourcesContent":["/**\n * Options for columns that can define a length of the column type.\n */\nexport interface ColumnUnsignedOptions {\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n * @deprecated MySQL deprecated and removed display width for integer types,\n * TypeORM will also remove it in an upcoming version. Use a character\n * column and the `LPAD` function as suggested by MySQL or handle the\n * formatting in the application layer.\n */\n width?: number\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds\n * the UNSIGNED attribute to this column\n * @deprecated MySQL deprecated and removed the zerofill attribute. This\n * will also be removed from TypeORM in an upcoming version. Use a character\n * column and the `LPAD` function as suggested by MySQL or handle the\n * formatting in the application layer.\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n}\n"],"sourceRoot":"../.."}
|
|
@@ -18,6 +18,9 @@ export interface PrimaryGeneratedColumnNumericOptions {
|
|
|
18
18
|
/**
|
|
19
19
|
* Puts ZEROFILL attribute on to numeric column. Works only for MySQL.
|
|
20
20
|
* If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column
|
|
21
|
+
* @deprecated No longer supported in newer MySQL versions, will be removed
|
|
22
|
+
* from TypeORM in an upcoming version. Use a character column and the
|
|
23
|
+
* `LPAD` function as suggested by MySQL
|
|
21
24
|
*/
|
|
22
25
|
zerofill?: boolean;
|
|
23
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/options/PrimaryGeneratedColumnNumericOptions.ts"],"names":[],"mappings":"","file":"PrimaryGeneratedColumnNumericOptions.js","sourcesContent":["import { PrimaryGeneratedColumnType } from \"../../driver/types/ColumnTypes\"\n\n/**\n * Describes all options for PrimaryGeneratedColumn decorator with numeric generation strategy.\n */\nexport interface PrimaryGeneratedColumnNumericOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: PrimaryGeneratedColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n\n /**\n * Name of the primary key constraint.\n */\n primaryKeyConstraintName?: string\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/options/PrimaryGeneratedColumnNumericOptions.ts"],"names":[],"mappings":"","file":"PrimaryGeneratedColumnNumericOptions.js","sourcesContent":["import { PrimaryGeneratedColumnType } from \"../../driver/types/ColumnTypes\"\n\n/**\n * Describes all options for PrimaryGeneratedColumn decorator with numeric generation strategy.\n */\nexport interface PrimaryGeneratedColumnNumericOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: PrimaryGeneratedColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n * @deprecated No longer supported in newer MySQL versions, will be removed\n * from TypeORM in an upcoming version. Use a character column and the\n * `LPAD` function as suggested by MySQL\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n\n /**\n * Name of the primary key constraint.\n */\n primaryKeyConstraintName?: string\n}\n"],"sourceRoot":"../.."}
|