typeorm 0.3.26-dev.aebc7eb → 0.3.26-dev.d1e3950
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/README.md +16 -1110
- package/browser/cache/RedisQueryResultCache.d.ts +13 -0
- package/browser/cache/RedisQueryResultCache.js +105 -38
- package/browser/cache/RedisQueryResultCache.js.map +1 -1
- package/browser/decorator/options/ColumnOptions.d.ts +6 -0
- package/browser/decorator/options/ColumnOptions.js.map +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachDriver.js +2 -2
- package/browser/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +4 -4
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/mongodb/MongoConnectionOptions.d.ts +9 -9
- package/browser/driver/mongodb/MongoConnectionOptions.js.map +1 -1
- package/browser/driver/mysql/MysqlDriver.js +3 -1
- package/browser/driver/mysql/MysqlDriver.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js +3 -3
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresDriver.js +2 -2
- package/browser/driver/postgres/PostgresDriver.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +5 -5
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.js +1 -1
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/spanner/SpannerQueryRunner.js +3 -3
- package/browser/driver/spanner/SpannerQueryRunner.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.js +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/browser/entity-schema/EntitySchemaColumnOptions.d.ts +10 -0
- package/browser/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
- package/browser/entity-schema/EntitySchemaTransformer.js +3 -0
- package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/browser/error/DriverPackageNotInstalledError.js +1 -2
- package/browser/error/DriverPackageNotInstalledError.js.map +1 -1
- package/browser/metadata-builder/EntityMetadataBuilder.js +8 -1
- package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/browser/platform/BrowserPlatformTools.js +7 -3
- package/browser/platform/BrowserPlatformTools.js.map +1 -1
- package/browser/query-builder/QueryExpressionMap.js +1 -0
- package/browser/query-builder/QueryExpressionMap.js.map +1 -1
- package/browser/repository/SaveOptions.d.ts +1 -1
- package/browser/repository/SaveOptions.js.map +1 -1
- package/cache/RedisQueryResultCache.d.ts +13 -0
- package/cache/RedisQueryResultCache.js +105 -38
- package/cache/RedisQueryResultCache.js.map +1 -1
- package/decorator/options/ColumnOptions.d.ts +6 -0
- package/decorator/options/ColumnOptions.js.map +1 -1
- package/driver/aurora-mysql/AuroraMysqlQueryRunner.js +1 -1
- package/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
- package/driver/cockroachdb/CockroachDriver.js +2 -2
- package/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +4 -4
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/mongodb/MongoConnectionOptions.d.ts +9 -9
- package/driver/mongodb/MongoConnectionOptions.js.map +1 -1
- package/driver/mysql/MysqlDriver.js +3 -1
- package/driver/mysql/MysqlDriver.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.js +3 -3
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.js +1 -1
- package/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresDriver.js +2 -2
- package/driver/postgres/PostgresDriver.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +5 -5
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.js +1 -1
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/spanner/SpannerQueryRunner.js +3 -3
- package/driver/spanner/SpannerQueryRunner.js.map +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.js +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/entity-schema/EntitySchemaColumnOptions.d.ts +10 -0
- package/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
- package/entity-schema/EntitySchemaTransformer.js +3 -0
- package/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/error/DriverPackageNotInstalledError.js +1 -2
- package/error/DriverPackageNotInstalledError.js.map +1 -1
- package/metadata-builder/EntityMetadataBuilder.js +8 -1
- package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/QueryExpressionMap.js +1 -0
- package/query-builder/QueryExpressionMap.js.map +1 -1
- package/repository/SaveOptions.d.ts +1 -1
- package/repository/SaveOptions.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/query-builder/QueryExpressionMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAA;AAOhF,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAKvC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IA4U3B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QA/U5C,4EAA4E;QAC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C,YAAY,KAAK,QAAQ;gBACvC,CAAC,CAAC,UAAU,CAAC,YAAY;gBACzB,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE;YACzC,OAAO,EAAE,UAAU,CAAC,OAAO;SAC9B,CAAC,CACL,CAAA;QACD,OAAO,GAAG,CAAA;IACd,CAAC;CACJ","file":"QueryExpressionMap.js","sourcesContent":["import { Alias } from \"./Alias\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { OrderByCondition } from \"../find-options/OrderByCondition\"\nimport { JoinAttribute } from \"./JoinAttribute\"\nimport { QueryBuilder } from \"./QueryBuilder\"\nimport { QueryBuilderCteOptions } from \"./QueryBuilderCte\"\nimport { RelationIdAttribute } from \"./relation-id/RelationIdAttribute\"\nimport { RelationCountAttribute } from \"./relation-count/RelationCountAttribute\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { SelectQuery } from \"./SelectQuery\"\nimport { ColumnMetadata } from \"../metadata/ColumnMetadata\"\nimport { RelationMetadata } from \"../metadata/RelationMetadata\"\nimport { SelectQueryBuilderOption } from \"./SelectQueryBuilderOption\"\nimport { TypeORMError } from \"../error\"\nimport { WhereClause } from \"./WhereClause\"\nimport { UpsertType } from \"../driver/types/UpsertType\"\nimport { CockroachConnectionOptions } from \"../driver/cockroachdb/CockroachConnectionOptions\"\n\n/**\n * Contains all properties of the QueryBuilder that needs to be build a final query.\n */\nexport class QueryExpressionMap {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Strategy to load relations.\n */\n relationLoadStrategy: \"join\" | \"query\" = \"join\"\n\n /**\n * Indicates if QueryBuilder used to select entities and not a raw results.\n */\n queryEntity: boolean = false\n\n /**\n * Main alias is a main selection object selected by QueryBuilder.\n */\n mainAlias?: Alias\n\n /**\n * All aliases (including main alias) used in the query.\n */\n aliases: Alias[] = []\n\n /**\n * Represents query type. QueryBuilder is able to build SELECT, UPDATE and DELETE queries.\n */\n queryType:\n | \"select\"\n | \"update\"\n | \"delete\"\n | \"insert\"\n | \"relation\"\n | \"soft-delete\"\n | \"restore\" = \"select\"\n\n /**\n * Data needs to be SELECT-ed.\n */\n selects: SelectQuery[] = []\n\n /**\n * Max execution time in millisecond.\n */\n maxExecutionTime: number = 0\n\n /**\n * Whether SELECT is DISTINCT.\n */\n selectDistinct: boolean = false\n\n /**\n * SELECT DISTINCT ON query (postgres).\n */\n selectDistinctOn: string[] = []\n\n /**\n * FROM-s to be selected.\n */\n // froms: { target: string, alias: string }[] = [];\n\n /**\n * If update query was used, it needs \"update set\" - properties which will be updated by this query.\n * If insert query was used, it needs \"insert set\" - values that needs to be inserted.\n */\n valuesSet?: ObjectLiteral | ObjectLiteral[]\n\n /**\n * Optional returning (or output) clause for insert, update or delete queries.\n */\n returning: string | string[]\n\n /**\n * Extra returning columns to be added to the returning statement if driver supports it.\n */\n extraReturningColumns: ColumnMetadata[] = []\n\n /**\n * Optional on conflict statement used in insertion query in postgres.\n */\n onConflict: string = \"\"\n\n /**\n * Optional on ignore statement used in insertion query in databases.\n */\n onIgnore: boolean = false\n\n /**\n * Optional on update statement used in insertion query in databases.\n */\n onUpdate: {\n conflict?: string | string[]\n columns?: string[]\n overwrite?: string[]\n skipUpdateIfNoValuesChanged?: boolean\n indexPredicate?: string\n upsertType?: UpsertType\n overwriteCondition?: WhereClause[]\n }\n\n /**\n * JOIN queries.\n */\n joinAttributes: JoinAttribute[] = []\n\n /**\n * RelationId queries.\n */\n relationIdAttributes: RelationIdAttribute[] = []\n\n /**\n * Relation count queries.\n */\n relationCountAttributes: RelationCountAttribute[] = []\n\n /**\n * WHERE queries.\n */\n wheres: WhereClause[] = []\n\n /**\n * HAVING queries.\n */\n havings: { type: \"simple\" | \"and\" | \"or\"; condition: string }[] = []\n\n /**\n * ORDER BY queries.\n */\n orderBys: OrderByCondition = {}\n\n /**\n * GROUP BY queries.\n */\n groupBys: string[] = []\n\n /**\n * LIMIT query.\n */\n limit?: number\n\n /**\n * OFFSET query.\n */\n offset?: number\n\n /**\n * Number of rows to skip of result using pagination.\n */\n skip?: number\n\n /**\n * Number of rows to take using pagination.\n */\n take?: number\n\n /**\n * Use certain index for the query.\n *\n * SELECT * FROM table_name USE INDEX (col1_index, col2_index) WHERE col1=1 AND col2=2 AND col3=3;\n */\n useIndex?: string\n\n /**\n * Locking mode.\n */\n lockMode?:\n | \"optimistic\"\n | \"pessimistic_read\"\n | \"pessimistic_write\"\n | \"dirty_read\"\n /*\n \"pessimistic_partial_write\" and \"pessimistic_write_or_fail\" are deprecated and\n will be removed in a future version.\n\n Use onLocked instead.\n */\n | \"pessimistic_partial_write\"\n | \"pessimistic_write_or_fail\"\n | \"for_no_key_update\"\n | \"for_key_share\"\n\n /**\n * Current version of the entity, used for locking.\n */\n lockVersion?: number | Date\n\n /**\n * Tables to be specified in the \"FOR UPDATE OF\" clause, referred by their alias\n */\n lockTables?: string[]\n\n /**\n * Modify behavior when encountering locked rows. NOWAIT or SKIP LOCKED\n */\n onLocked?: \"nowait\" | \"skip_locked\"\n\n /**\n * Indicates if soft-deleted rows should be included in entity result.\n * By default the soft-deleted rows are not included.\n */\n withDeleted: boolean = false\n\n /**\n * Parameters used to be escaped in final query.\n */\n parameters: ObjectLiteral = {}\n\n /**\n * Indicates if alias, table names and column names will be escaped by driver, or not.\n *\n * todo: rename to isQuotingDisabled, also think if it should be named \"escaping\"\n */\n disableEscaping: boolean = true\n\n /**\n * Indicates if virtual columns should be included in entity result.\n *\n * todo: what to do with it? is it properly used? what about persistence?\n */\n enableRelationIdValues: boolean = false\n\n /**\n * Extra where condition appended to the end of original where conditions with AND keyword.\n * Original condition will be wrapped into brackets.\n */\n extraAppendedAndWhereCondition: string = \"\"\n\n /**\n * Indicates if query builder creates a subquery.\n */\n subQuery: boolean = false\n\n /**\n * Indicates if property names are prefixed with alias names during property replacement.\n * By default this is enabled, however we need this because aliases are not supported in UPDATE and DELETE queries,\n * but user can use them in WHERE expressions.\n */\n aliasNamePrefixingEnabled: boolean = true\n\n /**\n * Indicates if query result cache is enabled or not.\n * It is undefined by default to avoid overriding the `alwaysEnabled` config\n */\n cache?: boolean\n\n /**\n * Time in milliseconds in which cache will expire.\n * If not set then global caching time will be used.\n */\n cacheDuration: number\n\n /**\n * Cache id.\n * Used to identifier your cache queries.\n */\n cacheId: string\n\n /**\n * Options that define QueryBuilder behaviour.\n */\n options: SelectQueryBuilderOption[] = []\n\n /**\n * Property path of relation to work with.\n * Used in relational query builder.\n */\n relationPropertyPath: string\n\n /**\n * Entity (target) which relations will be updated.\n */\n of: any | any[]\n\n /**\n * List of columns where data should be inserted.\n * Used in INSERT query.\n */\n insertColumns: string[] = []\n\n /**\n * Used if user wants to update or delete a specific entities.\n */\n whereEntities: ObjectLiteral[] = []\n\n /**\n * Indicates if entity must be updated after insertion / updation.\n * This may produce extra query or use RETURNING / OUTPUT statement (depend on database).\n */\n updateEntity: boolean = true\n\n /**\n * Indicates if listeners and subscribers must be called before and after query execution.\n */\n callListeners: boolean = true\n\n /**\n * Indicates if query must be wrapped into transaction.\n */\n useTransaction: boolean = false\n\n /**\n * Indicates if query should be time travel query\n * https://www.cockroachlabs.com/docs/stable/as-of-system-time.html\n */\n timeTravel?: boolean | string\n\n /**\n * Extra parameters.\n *\n * @deprecated Use standard parameters instead\n */\n nativeParameters: ObjectLiteral = {}\n\n /**\n * Query Comment to include extra information for debugging or other purposes.\n */\n comment?: string\n\n /**\n * Items from an entity that have been locally generated & are recorded here for later use.\n * Examples include the UUID generation when the database does not natively support it.\n * These are included in the entity index order.\n */\n locallyGenerated: { [key: number]: ObjectLiteral } = {}\n\n commonTableExpressions: {\n queryBuilder: QueryBuilder<any> | string\n alias: string\n options: QueryBuilderCteOptions\n }[] = []\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: DataSource) {\n if (connection.options.relationLoadStrategy) {\n this.relationLoadStrategy = connection.options.relationLoadStrategy\n }\n\n this.timeTravel =\n (connection.options as CockroachConnectionOptions)\n ?.timeTravelQueries || false\n }\n\n // -------------------------------------------------------------------------\n // Accessors\n // -------------------------------------------------------------------------\n\n /**\n * Get all ORDER BY queries - if order by is specified by user then it uses them,\n * otherwise it uses default entity order by if it was set.\n */\n get allOrderBys() {\n if (\n !Object.keys(this.orderBys).length &&\n this.mainAlias!.hasMetadata &&\n this.options.indexOf(\"disable-global-order\") === -1\n ) {\n const entityOrderBy = this.mainAlias!.metadata.orderBy || {}\n return Object.keys(entityOrderBy).reduce((orderBy, key) => {\n orderBy[this.mainAlias!.name + \".\" + key] = entityOrderBy[key]\n return orderBy\n }, {} as OrderByCondition)\n }\n\n return this.orderBys\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a main alias and adds it to the current expression map.\n */\n setMainAlias(alias: Alias): Alias {\n // if main alias is already set then remove it from the array\n // if (this.mainAlias)\n // this.aliases.splice(this.aliases.indexOf(this.mainAlias));\n\n // set new main alias\n this.mainAlias = alias\n\n return alias\n }\n\n /**\n * Creates a new alias and adds it to the current expression map.\n */\n createAlias(options: {\n type: \"from\" | \"select\" | \"join\" | \"other\"\n name?: string\n target?: Function | string\n tablePath?: string\n subQuery?: string\n metadata?: EntityMetadata\n }): Alias {\n let aliasName = options.name\n if (!aliasName && options.tablePath) aliasName = options.tablePath\n if (!aliasName && typeof options.target === \"function\")\n aliasName = options.target.name\n if (!aliasName && typeof options.target === \"string\")\n aliasName = options.target\n\n const alias = new Alias()\n alias.type = options.type\n if (aliasName) alias.name = aliasName\n if (options.metadata) alias.metadata = options.metadata\n if (options.target && !alias.hasMetadata)\n alias.metadata = this.connection.getMetadata(options.target)\n if (options.tablePath) alias.tablePath = options.tablePath\n if (options.subQuery) alias.subQuery = options.subQuery\n\n this.aliases.push(alias)\n return alias\n }\n\n /**\n * Finds alias with the given name.\n * If alias was not found it throw an exception.\n */\n findAliasByName(aliasName: string): Alias {\n const alias = this.aliases.find((alias) => alias.name === aliasName)\n if (!alias)\n throw new TypeORMError(\n `\"${aliasName}\" alias was not found. Maybe you forgot to join it?`,\n )\n\n return alias\n }\n\n findColumnByAliasExpression(\n aliasExpression: string,\n ): ColumnMetadata | undefined {\n const [aliasName, propertyPath] = aliasExpression.split(\".\")\n const alias = this.findAliasByName(aliasName)\n return alias.metadata.findColumnWithPropertyName(propertyPath)\n }\n\n /**\n * Gets relation metadata of the relation this query builder works with.\n *\n * todo: add proper exceptions\n */\n get relationMetadata(): RelationMetadata {\n if (!this.mainAlias)\n throw new TypeORMError(`Entity to work with is not specified!`) // todo: better message\n\n const relationMetadata =\n this.mainAlias.metadata.findRelationWithPropertyPath(\n this.relationPropertyPath,\n )\n if (!relationMetadata)\n throw new TypeORMError(\n `Relation ${this.relationPropertyPath} was not found in entity ${this.mainAlias.name}`,\n ) // todo: better message\n\n return relationMetadata\n }\n\n /**\n * Copies all properties of the current QueryExpressionMap into a new one.\n * Useful when QueryBuilder needs to create a copy of itself.\n */\n clone(): QueryExpressionMap {\n const map = new QueryExpressionMap(this.connection)\n map.queryType = this.queryType\n map.selects = this.selects.map((select) => select)\n map.maxExecutionTime = this.maxExecutionTime\n map.selectDistinct = this.selectDistinct\n map.selectDistinctOn = this.selectDistinctOn\n this.aliases.forEach((alias) => map.aliases.push(new Alias(alias)))\n map.relationLoadStrategy = this.relationLoadStrategy\n map.mainAlias = this.mainAlias\n map.valuesSet = this.valuesSet\n map.returning = this.returning\n map.onConflict = this.onConflict\n map.onIgnore = this.onIgnore\n map.onUpdate = this.onUpdate\n map.joinAttributes = this.joinAttributes.map(\n (join) => new JoinAttribute(this.connection, this, join),\n )\n map.relationIdAttributes = this.relationIdAttributes.map(\n (relationId) => new RelationIdAttribute(this, relationId),\n )\n map.relationCountAttributes = this.relationCountAttributes.map(\n (relationCount) => new RelationCountAttribute(this, relationCount),\n )\n map.wheres = this.wheres.map((where) => ({ ...where }))\n map.havings = this.havings.map((having) => ({ ...having }))\n map.orderBys = Object.assign({}, this.orderBys)\n map.groupBys = this.groupBys.map((groupBy) => groupBy)\n map.limit = this.limit\n map.offset = this.offset\n map.skip = this.skip\n map.take = this.take\n map.lockMode = this.lockMode\n map.onLocked = this.onLocked\n map.lockVersion = this.lockVersion\n map.lockTables = this.lockTables\n map.withDeleted = this.withDeleted\n map.parameters = Object.assign({}, this.parameters)\n map.disableEscaping = this.disableEscaping\n map.enableRelationIdValues = this.enableRelationIdValues\n map.extraAppendedAndWhereCondition = this.extraAppendedAndWhereCondition\n map.subQuery = this.subQuery\n map.aliasNamePrefixingEnabled = this.aliasNamePrefixingEnabled\n map.cache = this.cache\n map.cacheId = this.cacheId\n map.cacheDuration = this.cacheDuration\n map.relationPropertyPath = this.relationPropertyPath\n map.of = this.of\n map.insertColumns = this.insertColumns\n map.whereEntities = this.whereEntities\n map.updateEntity = this.updateEntity\n map.callListeners = this.callListeners\n map.useTransaction = this.useTransaction\n map.timeTravel = this.timeTravel\n map.nativeParameters = Object.assign({}, this.nativeParameters)\n map.comment = this.comment\n map.commonTableExpressions = this.commonTableExpressions.map(\n (cteOptions) => ({\n alias: cteOptions.alias,\n queryBuilder:\n typeof cteOptions.queryBuilder === \"string\"\n ? cteOptions.queryBuilder\n : cteOptions.queryBuilder.clone(),\n options: cteOptions.options,\n }),\n )\n return map\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/query-builder/QueryExpressionMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAA;AAOhF,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAKvC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IA4U3B,4EAA4E;I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sBAAsB,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CACxD,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACb,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,YAAY,EACR,OAAO,UAAU,CAAC,YAAY,KAAK,QAAQ;gBACvC,CAAC,CAAC,UAAU,CAAC,YAAY;gBACzB,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE;YACzC,OAAO,EAAE,UAAU,CAAC,OAAO;SAC9B,CAAC,CACL,CAAA;QACD,OAAO,GAAG,CAAA;IACd,CAAC;CACJ","file":"QueryExpressionMap.js","sourcesContent":["import { Alias } from \"./Alias\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { OrderByCondition } from \"../find-options/OrderByCondition\"\nimport { JoinAttribute } from \"./JoinAttribute\"\nimport { QueryBuilder } from \"./QueryBuilder\"\nimport { QueryBuilderCteOptions } from \"./QueryBuilderCte\"\nimport { RelationIdAttribute } from \"./relation-id/RelationIdAttribute\"\nimport { RelationCountAttribute } from \"./relation-count/RelationCountAttribute\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { SelectQuery } from \"./SelectQuery\"\nimport { ColumnMetadata } from \"../metadata/ColumnMetadata\"\nimport { RelationMetadata } from \"../metadata/RelationMetadata\"\nimport { SelectQueryBuilderOption } from \"./SelectQueryBuilderOption\"\nimport { TypeORMError } from \"../error\"\nimport { WhereClause } from \"./WhereClause\"\nimport { UpsertType } from \"../driver/types/UpsertType\"\nimport { CockroachConnectionOptions } from \"../driver/cockroachdb/CockroachConnectionOptions\"\n\n/**\n * Contains all properties of the QueryBuilder that needs to be build a final query.\n */\nexport class QueryExpressionMap {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Strategy to load relations.\n */\n relationLoadStrategy: \"join\" | \"query\" = \"join\"\n\n /**\n * Indicates if QueryBuilder used to select entities and not a raw results.\n */\n queryEntity: boolean = false\n\n /**\n * Main alias is a main selection object selected by QueryBuilder.\n */\n mainAlias?: Alias\n\n /**\n * All aliases (including main alias) used in the query.\n */\n aliases: Alias[] = []\n\n /**\n * Represents query type. QueryBuilder is able to build SELECT, UPDATE and DELETE queries.\n */\n queryType:\n | \"select\"\n | \"update\"\n | \"delete\"\n | \"insert\"\n | \"relation\"\n | \"soft-delete\"\n | \"restore\" = \"select\"\n\n /**\n * Data needs to be SELECT-ed.\n */\n selects: SelectQuery[] = []\n\n /**\n * Max execution time in millisecond.\n */\n maxExecutionTime: number = 0\n\n /**\n * Whether SELECT is DISTINCT.\n */\n selectDistinct: boolean = false\n\n /**\n * SELECT DISTINCT ON query (postgres).\n */\n selectDistinctOn: string[] = []\n\n /**\n * FROM-s to be selected.\n */\n // froms: { target: string, alias: string }[] = [];\n\n /**\n * If update query was used, it needs \"update set\" - properties which will be updated by this query.\n * If insert query was used, it needs \"insert set\" - values that needs to be inserted.\n */\n valuesSet?: ObjectLiteral | ObjectLiteral[]\n\n /**\n * Optional returning (or output) clause for insert, update or delete queries.\n */\n returning: string | string[]\n\n /**\n * Extra returning columns to be added to the returning statement if driver supports it.\n */\n extraReturningColumns: ColumnMetadata[] = []\n\n /**\n * Optional on conflict statement used in insertion query in postgres.\n */\n onConflict: string = \"\"\n\n /**\n * Optional on ignore statement used in insertion query in databases.\n */\n onIgnore: boolean = false\n\n /**\n * Optional on update statement used in insertion query in databases.\n */\n onUpdate: {\n conflict?: string | string[]\n columns?: string[]\n overwrite?: string[]\n skipUpdateIfNoValuesChanged?: boolean\n indexPredicate?: string\n upsertType?: UpsertType\n overwriteCondition?: WhereClause[]\n }\n\n /**\n * JOIN queries.\n */\n joinAttributes: JoinAttribute[] = []\n\n /**\n * RelationId queries.\n */\n relationIdAttributes: RelationIdAttribute[] = []\n\n /**\n * Relation count queries.\n */\n relationCountAttributes: RelationCountAttribute[] = []\n\n /**\n * WHERE queries.\n */\n wheres: WhereClause[] = []\n\n /**\n * HAVING queries.\n */\n havings: { type: \"simple\" | \"and\" | \"or\"; condition: string }[] = []\n\n /**\n * ORDER BY queries.\n */\n orderBys: OrderByCondition = {}\n\n /**\n * GROUP BY queries.\n */\n groupBys: string[] = []\n\n /**\n * LIMIT query.\n */\n limit?: number\n\n /**\n * OFFSET query.\n */\n offset?: number\n\n /**\n * Number of rows to skip of result using pagination.\n */\n skip?: number\n\n /**\n * Number of rows to take using pagination.\n */\n take?: number\n\n /**\n * Use certain index for the query.\n *\n * SELECT * FROM table_name USE INDEX (col1_index, col2_index) WHERE col1=1 AND col2=2 AND col3=3;\n */\n useIndex?: string\n\n /**\n * Locking mode.\n */\n lockMode?:\n | \"optimistic\"\n | \"pessimistic_read\"\n | \"pessimistic_write\"\n | \"dirty_read\"\n /*\n \"pessimistic_partial_write\" and \"pessimistic_write_or_fail\" are deprecated and\n will be removed in a future version.\n\n Use onLocked instead.\n */\n | \"pessimistic_partial_write\"\n | \"pessimistic_write_or_fail\"\n | \"for_no_key_update\"\n | \"for_key_share\"\n\n /**\n * Current version of the entity, used for locking.\n */\n lockVersion?: number | Date\n\n /**\n * Tables to be specified in the \"FOR UPDATE OF\" clause, referred by their alias\n */\n lockTables?: string[]\n\n /**\n * Modify behavior when encountering locked rows. NOWAIT or SKIP LOCKED\n */\n onLocked?: \"nowait\" | \"skip_locked\"\n\n /**\n * Indicates if soft-deleted rows should be included in entity result.\n * By default the soft-deleted rows are not included.\n */\n withDeleted: boolean = false\n\n /**\n * Parameters used to be escaped in final query.\n */\n parameters: ObjectLiteral = {}\n\n /**\n * Indicates if alias, table names and column names will be escaped by driver, or not.\n *\n * todo: rename to isQuotingDisabled, also think if it should be named \"escaping\"\n */\n disableEscaping: boolean = true\n\n /**\n * Indicates if virtual columns should be included in entity result.\n *\n * todo: what to do with it? is it properly used? what about persistence?\n */\n enableRelationIdValues: boolean = false\n\n /**\n * Extra where condition appended to the end of original where conditions with AND keyword.\n * Original condition will be wrapped into brackets.\n */\n extraAppendedAndWhereCondition: string = \"\"\n\n /**\n * Indicates if query builder creates a subquery.\n */\n subQuery: boolean = false\n\n /**\n * Indicates if property names are prefixed with alias names during property replacement.\n * By default this is enabled, however we need this because aliases are not supported in UPDATE and DELETE queries,\n * but user can use them in WHERE expressions.\n */\n aliasNamePrefixingEnabled: boolean = true\n\n /**\n * Indicates if query result cache is enabled or not.\n * It is undefined by default to avoid overriding the `alwaysEnabled` config\n */\n cache?: boolean\n\n /**\n * Time in milliseconds in which cache will expire.\n * If not set then global caching time will be used.\n */\n cacheDuration: number\n\n /**\n * Cache id.\n * Used to identifier your cache queries.\n */\n cacheId: string\n\n /**\n * Options that define QueryBuilder behaviour.\n */\n options: SelectQueryBuilderOption[] = []\n\n /**\n * Property path of relation to work with.\n * Used in relational query builder.\n */\n relationPropertyPath: string\n\n /**\n * Entity (target) which relations will be updated.\n */\n of: any | any[]\n\n /**\n * List of columns where data should be inserted.\n * Used in INSERT query.\n */\n insertColumns: string[] = []\n\n /**\n * Used if user wants to update or delete a specific entities.\n */\n whereEntities: ObjectLiteral[] = []\n\n /**\n * Indicates if entity must be updated after insertion / updation.\n * This may produce extra query or use RETURNING / OUTPUT statement (depend on database).\n */\n updateEntity: boolean = true\n\n /**\n * Indicates if listeners and subscribers must be called before and after query execution.\n */\n callListeners: boolean = true\n\n /**\n * Indicates if query must be wrapped into transaction.\n */\n useTransaction: boolean = false\n\n /**\n * Indicates if query should be time travel query\n * https://www.cockroachlabs.com/docs/stable/as-of-system-time.html\n */\n timeTravel?: boolean | string\n\n /**\n * Extra parameters.\n *\n * @deprecated Use standard parameters instead\n */\n nativeParameters: ObjectLiteral = {}\n\n /**\n * Query Comment to include extra information for debugging or other purposes.\n */\n comment?: string\n\n /**\n * Items from an entity that have been locally generated & are recorded here for later use.\n * Examples include the UUID generation when the database does not natively support it.\n * These are included in the entity index order.\n */\n locallyGenerated: { [key: number]: ObjectLiteral } = {}\n\n commonTableExpressions: {\n queryBuilder: QueryBuilder<any> | string\n alias: string\n options: QueryBuilderCteOptions\n }[] = []\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: DataSource) {\n if (connection.options.relationLoadStrategy) {\n this.relationLoadStrategy = connection.options.relationLoadStrategy\n }\n\n this.timeTravel =\n (connection.options as CockroachConnectionOptions)\n ?.timeTravelQueries || false\n }\n\n // -------------------------------------------------------------------------\n // Accessors\n // -------------------------------------------------------------------------\n\n /**\n * Get all ORDER BY queries - if order by is specified by user then it uses them,\n * otherwise it uses default entity order by if it was set.\n */\n get allOrderBys() {\n if (\n !Object.keys(this.orderBys).length &&\n this.mainAlias!.hasMetadata &&\n this.options.indexOf(\"disable-global-order\") === -1\n ) {\n const entityOrderBy = this.mainAlias!.metadata.orderBy || {}\n return Object.keys(entityOrderBy).reduce((orderBy, key) => {\n orderBy[this.mainAlias!.name + \".\" + key] = entityOrderBy[key]\n return orderBy\n }, {} as OrderByCondition)\n }\n\n return this.orderBys\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a main alias and adds it to the current expression map.\n */\n setMainAlias(alias: Alias): Alias {\n // if main alias is already set then remove it from the array\n // if (this.mainAlias)\n // this.aliases.splice(this.aliases.indexOf(this.mainAlias));\n\n // set new main alias\n this.mainAlias = alias\n\n return alias\n }\n\n /**\n * Creates a new alias and adds it to the current expression map.\n */\n createAlias(options: {\n type: \"from\" | \"select\" | \"join\" | \"other\"\n name?: string\n target?: Function | string\n tablePath?: string\n subQuery?: string\n metadata?: EntityMetadata\n }): Alias {\n let aliasName = options.name\n if (!aliasName && options.tablePath) aliasName = options.tablePath\n if (!aliasName && typeof options.target === \"function\")\n aliasName = options.target.name\n if (!aliasName && typeof options.target === \"string\")\n aliasName = options.target\n\n const alias = new Alias()\n alias.type = options.type\n if (aliasName) alias.name = aliasName\n if (options.metadata) alias.metadata = options.metadata\n if (options.target && !alias.hasMetadata)\n alias.metadata = this.connection.getMetadata(options.target)\n if (options.tablePath) alias.tablePath = options.tablePath\n if (options.subQuery) alias.subQuery = options.subQuery\n\n this.aliases.push(alias)\n return alias\n }\n\n /**\n * Finds alias with the given name.\n * If alias was not found it throw an exception.\n */\n findAliasByName(aliasName: string): Alias {\n const alias = this.aliases.find((alias) => alias.name === aliasName)\n if (!alias)\n throw new TypeORMError(\n `\"${aliasName}\" alias was not found. Maybe you forgot to join it?`,\n )\n\n return alias\n }\n\n findColumnByAliasExpression(\n aliasExpression: string,\n ): ColumnMetadata | undefined {\n const [aliasName, propertyPath] = aliasExpression.split(\".\")\n const alias = this.findAliasByName(aliasName)\n return alias.metadata.findColumnWithPropertyName(propertyPath)\n }\n\n /**\n * Gets relation metadata of the relation this query builder works with.\n *\n * todo: add proper exceptions\n */\n get relationMetadata(): RelationMetadata {\n if (!this.mainAlias)\n throw new TypeORMError(`Entity to work with is not specified!`) // todo: better message\n\n const relationMetadata =\n this.mainAlias.metadata.findRelationWithPropertyPath(\n this.relationPropertyPath,\n )\n if (!relationMetadata)\n throw new TypeORMError(\n `Relation ${this.relationPropertyPath} was not found in entity ${this.mainAlias.name}`,\n ) // todo: better message\n\n return relationMetadata\n }\n\n /**\n * Copies all properties of the current QueryExpressionMap into a new one.\n * Useful when QueryBuilder needs to create a copy of itself.\n */\n clone(): QueryExpressionMap {\n const map = new QueryExpressionMap(this.connection)\n map.queryType = this.queryType\n map.selects = this.selects.map((select) => select)\n map.maxExecutionTime = this.maxExecutionTime\n map.selectDistinct = this.selectDistinct\n map.selectDistinctOn = this.selectDistinctOn\n this.aliases.forEach((alias) => map.aliases.push(new Alias(alias)))\n map.relationLoadStrategy = this.relationLoadStrategy\n map.mainAlias = this.mainAlias\n map.valuesSet = this.valuesSet\n map.returning = this.returning\n map.onConflict = this.onConflict\n map.onIgnore = this.onIgnore\n map.onUpdate = this.onUpdate\n map.joinAttributes = this.joinAttributes.map(\n (join) => new JoinAttribute(this.connection, this, join),\n )\n map.relationIdAttributes = this.relationIdAttributes.map(\n (relationId) => new RelationIdAttribute(this, relationId),\n )\n map.relationCountAttributes = this.relationCountAttributes.map(\n (relationCount) => new RelationCountAttribute(this, relationCount),\n )\n map.wheres = this.wheres.map((where) => ({ ...where }))\n map.havings = this.havings.map((having) => ({ ...having }))\n map.orderBys = Object.assign({}, this.orderBys)\n map.groupBys = this.groupBys.map((groupBy) => groupBy)\n map.limit = this.limit\n map.offset = this.offset\n map.skip = this.skip\n map.take = this.take\n map.useIndex = this.useIndex\n map.lockMode = this.lockMode\n map.onLocked = this.onLocked\n map.lockVersion = this.lockVersion\n map.lockTables = this.lockTables\n map.withDeleted = this.withDeleted\n map.parameters = Object.assign({}, this.parameters)\n map.disableEscaping = this.disableEscaping\n map.enableRelationIdValues = this.enableRelationIdValues\n map.extraAppendedAndWhereCondition = this.extraAppendedAndWhereCondition\n map.subQuery = this.subQuery\n map.aliasNamePrefixingEnabled = this.aliasNamePrefixingEnabled\n map.cache = this.cache\n map.cacheId = this.cacheId\n map.cacheDuration = this.cacheDuration\n map.relationPropertyPath = this.relationPropertyPath\n map.of = this.of\n map.insertColumns = this.insertColumns\n map.whereEntities = this.whereEntities\n map.updateEntity = this.updateEntity\n map.callListeners = this.callListeners\n map.useTransaction = this.useTransaction\n map.timeTravel = this.timeTravel\n map.nativeParameters = Object.assign({}, this.nativeParameters)\n map.comment = this.comment\n map.commonTableExpressions = this.commonTableExpressions.map(\n (cteOptions) => ({\n alias: cteOptions.alias,\n queryBuilder:\n typeof cteOptions.queryBuilder === \"string\"\n ? cteOptions.queryBuilder\n : cteOptions.queryBuilder.clone(),\n options: cteOptions.options,\n }),\n )\n return map\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -28,7 +28,7 @@ export interface SaveOptions {
|
|
|
28
28
|
* Flag to determine whether the entity that is being persisted
|
|
29
29
|
* should be reloaded during the persistence operation.
|
|
30
30
|
*
|
|
31
|
-
* It will work only on databases which
|
|
31
|
+
* It will work only on databases which do not support RETURNING / OUTPUT statement.
|
|
32
32
|
* Enabled by default.
|
|
33
33
|
*/
|
|
34
34
|
reload?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/repository/SaveOptions.ts"],"names":[],"mappings":"","file":"SaveOptions.js","sourcesContent":["/**\n * Special options passed to Repository#save, Repository#insert and Repository#update methods.\n */\nexport interface SaveOptions {\n /**\n * Additional data to be passed with persist method.\n * This data can be used in subscribers then.\n */\n data?: any\n\n /**\n * Indicates if listeners and subscribers are called for this operation.\n * By default they are enabled, you can disable them by setting { listeners: false } in save/remove options.\n */\n listeners?: boolean\n\n /**\n * By default transactions are enabled and all queries in persistence operation are wrapped into the transaction.\n * You can disable this behaviour by setting { transaction: false } in the persistence options.\n */\n transaction?: boolean\n\n /**\n * Breaks save execution into chunks of a given size.\n * For example, if you want to save 100,000 objects but you have issues with saving them,\n * you can break them into 10 groups of 10,000 objects (by setting { chunk: 10000 }) and save each group separately.\n * This option is needed to perform very big insertions when you have issues with underlying driver parameter number limitation.\n */\n chunk?: number\n\n /**\n * Flag to determine whether the entity that is being persisted\n * should be reloaded during the persistence operation.\n *\n * It will work only on databases which
|
|
1
|
+
{"version":3,"sources":["../browser/src/repository/SaveOptions.ts"],"names":[],"mappings":"","file":"SaveOptions.js","sourcesContent":["/**\n * Special options passed to Repository#save, Repository#insert and Repository#update methods.\n */\nexport interface SaveOptions {\n /**\n * Additional data to be passed with persist method.\n * This data can be used in subscribers then.\n */\n data?: any\n\n /**\n * Indicates if listeners and subscribers are called for this operation.\n * By default they are enabled, you can disable them by setting { listeners: false } in save/remove options.\n */\n listeners?: boolean\n\n /**\n * By default transactions are enabled and all queries in persistence operation are wrapped into the transaction.\n * You can disable this behaviour by setting { transaction: false } in the persistence options.\n */\n transaction?: boolean\n\n /**\n * Breaks save execution into chunks of a given size.\n * For example, if you want to save 100,000 objects but you have issues with saving them,\n * you can break them into 10 groups of 10,000 objects (by setting { chunk: 10000 }) and save each group separately.\n * This option is needed to perform very big insertions when you have issues with underlying driver parameter number limitation.\n */\n chunk?: number\n\n /**\n * Flag to determine whether the entity that is being persisted\n * should be reloaded during the persistence operation.\n *\n * It will work only on databases which do not support RETURNING / OUTPUT statement.\n * Enabled by default.\n */\n reload?: boolean\n}\n"],"sourceRoot":".."}
|
|
@@ -19,6 +19,10 @@ export declare class RedisQueryResultCache implements QueryResultCache {
|
|
|
19
19
|
* Type of the Redis Client (redis or ioredis).
|
|
20
20
|
*/
|
|
21
21
|
protected clientType: "redis" | "ioredis" | "ioredis/cluster";
|
|
22
|
+
/**
|
|
23
|
+
* Redis major version number
|
|
24
|
+
*/
|
|
25
|
+
protected redisMajorVersion: number | undefined;
|
|
22
26
|
constructor(connection: DataSource, clientType: "redis" | "ioredis" | "ioredis/cluster");
|
|
23
27
|
/**
|
|
24
28
|
* Creates a connection with given cache provider.
|
|
@@ -62,4 +66,13 @@ export declare class RedisQueryResultCache implements QueryResultCache {
|
|
|
62
66
|
* Loads redis dependency.
|
|
63
67
|
*/
|
|
64
68
|
protected loadRedis(): any;
|
|
69
|
+
/**
|
|
70
|
+
* Detects the Redis version based on the connected client's API characteristics
|
|
71
|
+
* without creating test keys in the database
|
|
72
|
+
*/
|
|
73
|
+
private detectRedisVersion;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if Redis version is 5.x or higher
|
|
76
|
+
*/
|
|
77
|
+
private isRedis5OrHigher;
|
|
65
78
|
}
|
|
@@ -24,19 +24,32 @@ class RedisQueryResultCache {
|
|
|
24
24
|
async connect() {
|
|
25
25
|
const cacheOptions = this.connection.options.cache;
|
|
26
26
|
if (this.clientType === "redis") {
|
|
27
|
-
|
|
27
|
+
const clientOptions = {
|
|
28
28
|
...cacheOptions?.options,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
};
|
|
30
|
+
// Create initial client to test Redis version
|
|
31
|
+
let tempClient = this.redis.createClient(clientOptions);
|
|
32
|
+
const isRedis4Plus = typeof tempClient.connect === "function";
|
|
33
|
+
if (isRedis4Plus) {
|
|
34
|
+
// Redis 4+ detected, recreate with legacyMode for Redis 4.x
|
|
35
|
+
// (Redis 5 will ignore legacyMode if not needed)
|
|
36
|
+
clientOptions.legacyMode = true;
|
|
37
|
+
tempClient = this.redis.createClient(clientOptions);
|
|
38
|
+
}
|
|
39
|
+
// Set as the main client
|
|
40
|
+
this.client = tempClient;
|
|
31
41
|
if (typeof this.connection.options.cache === "object" &&
|
|
32
42
|
this.connection.options.cache.ignoreErrors) {
|
|
33
43
|
this.client.on("error", (err) => {
|
|
34
44
|
this.connection.logger.log("warn", err);
|
|
35
45
|
});
|
|
36
46
|
}
|
|
37
|
-
|
|
47
|
+
// Connect if Redis 4+
|
|
48
|
+
if (typeof this.client.connect === "function") {
|
|
38
49
|
await this.client.connect();
|
|
39
50
|
}
|
|
51
|
+
// Detect precise version after connection is established
|
|
52
|
+
this.detectRedisVersion();
|
|
40
53
|
}
|
|
41
54
|
else if (this.clientType === "ioredis") {
|
|
42
55
|
if (cacheOptions && cacheOptions.port) {
|
|
@@ -74,6 +87,13 @@ class RedisQueryResultCache {
|
|
|
74
87
|
* Disconnects the connection
|
|
75
88
|
*/
|
|
76
89
|
async disconnect() {
|
|
90
|
+
if (this.isRedis5OrHigher()) {
|
|
91
|
+
// Redis 5+ uses quit() that returns a Promise
|
|
92
|
+
await this.client.quit();
|
|
93
|
+
this.client = undefined;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Redis 3/4 callback style
|
|
77
97
|
return new Promise((ok, fail) => {
|
|
78
98
|
this.client.quit((err, result) => {
|
|
79
99
|
if (err)
|
|
@@ -93,24 +113,22 @@ class RedisQueryResultCache {
|
|
|
93
113
|
* Returns undefined if result is not cached.
|
|
94
114
|
*/
|
|
95
115
|
getFromCache(options, queryRunner) {
|
|
116
|
+
const key = options.identifier || options.query;
|
|
117
|
+
if (!key)
|
|
118
|
+
return Promise.resolve(undefined);
|
|
119
|
+
if (this.isRedis5OrHigher()) {
|
|
120
|
+
// Redis 5+ Promise-based API
|
|
121
|
+
return this.client.get(key).then((result) => {
|
|
122
|
+
return result ? JSON.parse(result) : undefined;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// Redis 3/4 callback-based API
|
|
96
126
|
return new Promise((ok, fail) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
else if (options.query) {
|
|
105
|
-
this.client.get(options.query, (err, result) => {
|
|
106
|
-
if (err)
|
|
107
|
-
return fail(err);
|
|
108
|
-
ok(JSON.parse(result));
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
ok(undefined);
|
|
113
|
-
}
|
|
127
|
+
this.client.get(key, (err, result) => {
|
|
128
|
+
if (err)
|
|
129
|
+
return fail(err);
|
|
130
|
+
ok(result ? JSON.parse(result) : undefined);
|
|
131
|
+
});
|
|
114
132
|
});
|
|
115
133
|
}
|
|
116
134
|
/**
|
|
@@ -123,27 +141,37 @@ class RedisQueryResultCache {
|
|
|
123
141
|
* Stores given query result in the cache.
|
|
124
142
|
*/
|
|
125
143
|
async storeInCache(options, savedCache, queryRunner) {
|
|
144
|
+
const key = options.identifier || options.query;
|
|
145
|
+
if (!key)
|
|
146
|
+
return;
|
|
147
|
+
const value = JSON.stringify(options);
|
|
148
|
+
const duration = options.duration;
|
|
149
|
+
if (this.isRedis5OrHigher()) {
|
|
150
|
+
// Redis 5+ Promise-based API with PX option
|
|
151
|
+
await this.client.set(key, value, {
|
|
152
|
+
PX: duration,
|
|
153
|
+
});
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// Redis 3/4 callback-based API
|
|
126
157
|
return new Promise((ok, fail) => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
else if (options.query) {
|
|
135
|
-
this.client.set(options.query, JSON.stringify(options), "PX", options.duration, (err, result) => {
|
|
136
|
-
if (err)
|
|
137
|
-
return fail(err);
|
|
138
|
-
ok();
|
|
139
|
-
});
|
|
140
|
-
}
|
|
158
|
+
this.client.set(key, value, "PX", duration, (err, result) => {
|
|
159
|
+
if (err)
|
|
160
|
+
return fail(err);
|
|
161
|
+
ok();
|
|
162
|
+
});
|
|
141
163
|
});
|
|
142
164
|
}
|
|
143
165
|
/**
|
|
144
166
|
* Clears everything stored in the cache.
|
|
145
167
|
*/
|
|
146
168
|
async clear(queryRunner) {
|
|
169
|
+
if (this.isRedis5OrHigher()) {
|
|
170
|
+
// Redis 5+ Promise-based API
|
|
171
|
+
await this.client.flushDb();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
// Redis 3/4 callback-based API
|
|
147
175
|
return new Promise((ok, fail) => {
|
|
148
176
|
this.client.flushdb((err, result) => {
|
|
149
177
|
if (err)
|
|
@@ -166,7 +194,13 @@ class RedisQueryResultCache {
|
|
|
166
194
|
/**
|
|
167
195
|
* Removes a single key from redis database.
|
|
168
196
|
*/
|
|
169
|
-
deleteKey(key) {
|
|
197
|
+
async deleteKey(key) {
|
|
198
|
+
if (this.isRedis5OrHigher()) {
|
|
199
|
+
// Redis 5+ Promise-based API
|
|
200
|
+
await this.client.del(key);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
// Redis 3/4 callback-based API
|
|
170
204
|
return new Promise((ok, fail) => {
|
|
171
205
|
this.client.del(key, (err, result) => {
|
|
172
206
|
if (err)
|
|
@@ -187,10 +221,43 @@ class RedisQueryResultCache {
|
|
|
187
221
|
return PlatformTools_1.PlatformTools.load(this.clientType);
|
|
188
222
|
}
|
|
189
223
|
}
|
|
190
|
-
catch
|
|
191
|
-
throw new TypeORMError_1.TypeORMError(`Cannot use cache because ${this.clientType} is not installed. Please run "npm i ${this.clientType}
|
|
224
|
+
catch {
|
|
225
|
+
throw new TypeORMError_1.TypeORMError(`Cannot use cache because ${this.clientType} is not installed. Please run "npm i ${this.clientType}".`);
|
|
192
226
|
}
|
|
193
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Detects the Redis version based on the connected client's API characteristics
|
|
230
|
+
* without creating test keys in the database
|
|
231
|
+
*/
|
|
232
|
+
detectRedisVersion() {
|
|
233
|
+
if (this.clientType !== "redis")
|
|
234
|
+
return;
|
|
235
|
+
try {
|
|
236
|
+
// Detect version by examining the client's method signatures
|
|
237
|
+
// This avoids creating test keys in the database
|
|
238
|
+
const setMethod = this.client.set;
|
|
239
|
+
if (setMethod && setMethod.length <= 3) {
|
|
240
|
+
// Redis 5+ set method accepts fewer parameters (key, value, options)
|
|
241
|
+
this.redisMajorVersion = 5;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
// Redis 3/4 set method requires more parameters (key, value, flag, duration, callback)
|
|
245
|
+
this.redisMajorVersion = 3;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// Default to Redis 3/4 for maximum compatibility
|
|
250
|
+
this.redisMajorVersion = 3;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Checks if Redis version is 5.x or higher
|
|
255
|
+
*/
|
|
256
|
+
isRedis5OrHigher() {
|
|
257
|
+
if (this.clientType !== "redis")
|
|
258
|
+
return false;
|
|
259
|
+
return (this.redisMajorVersion !== undefined && this.redisMajorVersion >= 5);
|
|
260
|
+
}
|
|
194
261
|
}
|
|
195
262
|
exports.RedisQueryResultCache = RedisQueryResultCache;
|
|
196
263
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cache/RedisQueryResultCache.ts"],"names":[],"mappings":";;;AAEA,6DAAyD;AAGzD,wDAAoD;AAEpD;;GAEG;AACH,MAAa,qBAAqB;IAoB9B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,UAAsB,EAChC,UAAmD;QADzC,eAAU,GAAV,UAAU,CAAY;QAGhC,IAAI,CAAC,UAAU,GAAG,UAAU,CA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B;QAEzB,MAAM,OAAO,CAAC,GAAG,CACb,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QACrC,CAAC,CAAC,CACL,CAAA;IACL,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;IACO,SAAS,CAAC,GAAW;QAC3B,OAAO,IAAI,OAAO,CAAO,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAQ,EAAE,MAAW,EAAE,EAAE;gBAC3C,IAAI,GAAG;oBAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;gBACzB,EAAE,EAAE,CAAA;YACR,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC;IAED;;OAEG;IACO,SAAS;QACf,IAAI,CAAC;YACD,IAAI,IAAI,CAAC,UAAU,KAAK,iBAAiB,EAAE,CAAC;gBACxC,OAAO,6BAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YACxC,CAAC;iBAAM,CAAC;gBACJ,OAAO,6BAAa,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YAC9C,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,MAAM,IAAI,2BAAY,CAClB,4BAA4B,IAAI,CAAC,UAAU,wCAAwC,IAAI,CAAC,UAAU,WAAW,CAChH,CAAA;QACL,CAAC;IACL,CAAC;CACJ;AAhPD,sDAgPC","file":"RedisQueryResultCache.js","sourcesContent":["import { QueryResultCache } from \"./QueryResultCache\"\nimport { QueryResultCacheOptions } from \"./QueryResultCacheOptions\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { TypeORMError } from \"../error/TypeORMError\"\n\n/**\n * Caches query result into Redis database.\n */\nexport class RedisQueryResultCache implements QueryResultCache {\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Redis module instance loaded dynamically.\n */\n protected redis: any\n\n /**\n * Connected redis client.\n */\n protected client: any\n\n /**\n * Type of the Redis Client (redis or ioredis).\n */\n protected clientType: \"redis\" | \"ioredis\" | \"ioredis/cluster\"\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected connection: DataSource,\n clientType: \"redis\" | \"ioredis\" | \"ioredis/cluster\",\n ) {\n this.clientType = clientType\n this.redis = this.loadRedis()\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a connection with given cache provider.\n */\n async connect(): Promise<void> {\n const cacheOptions: any = this.connection.options.cache\n if (this.clientType === \"redis\") {\n this.client = this.redis.createClient({\n ...cacheOptions?.options,\n legacyMode: true,\n })\n if (\n typeof this.connection.options.cache === \"object\" &&\n this.connection.options.cache.ignoreErrors\n ) {\n this.client.on(\"error\", (err: any) => {\n this.connection.logger.log(\"warn\", err)\n })\n }\n if (\"connect\" in this.client) {\n await this.client.connect()\n }\n } else if (this.clientType === \"ioredis\") {\n if (cacheOptions && cacheOptions.port) {\n if (cacheOptions.options) {\n this.client = new this.redis(\n cacheOptions.port,\n cacheOptions.options,\n )\n } else {\n this.client = new this.redis(cacheOptions.port)\n }\n } else if (cacheOptions && cacheOptions.options) {\n this.client = new this.redis(cacheOptions.options)\n } else {\n this.client = new this.redis()\n }\n } else if (this.clientType === \"ioredis/cluster\") {\n if (\n cacheOptions &&\n cacheOptions.options &&\n Array.isArray(cacheOptions.options)\n ) {\n this.client = new this.redis.Cluster(cacheOptions.options)\n } else if (\n cacheOptions &&\n cacheOptions.options &&\n cacheOptions.options.startupNodes\n ) {\n this.client = new this.redis.Cluster(\n cacheOptions.options.startupNodes,\n cacheOptions.options.options,\n )\n } else {\n throw new TypeORMError(\n `options.startupNodes required for ${this.clientType}.`,\n )\n }\n }\n }\n\n /**\n * Disconnects the connection\n */\n async disconnect(): Promise<void> {\n return new Promise<void>((ok, fail) => {\n this.client.quit((err: any, result: any) => {\n if (err) return fail(err)\n ok()\n this.client = undefined\n })\n })\n }\n\n /**\n * Creates table for storing cache if it does not exist yet.\n */\n async synchronize(queryRunner: QueryRunner): Promise<void> {}\n\n /**\n * Get data from cache.\n * Returns cache result if found.\n * Returns undefined if result is not cached.\n */\n getFromCache(\n options: QueryResultCacheOptions,\n queryRunner?: QueryRunner,\n ): Promise<QueryResultCacheOptions | undefined> {\n return new Promise<QueryResultCacheOptions | undefined>((ok, fail) => {\n if (options.identifier) {\n this.client.get(options.identifier, (err: any, result: any) => {\n if (err) return fail(err)\n ok(JSON.parse(result))\n })\n } else if (options.query) {\n this.client.get(options.query, (err: any, result: any) => {\n if (err) return fail(err)\n ok(JSON.parse(result))\n })\n } else {\n ok(undefined)\n }\n })\n }\n\n /**\n * Checks if cache is expired or not.\n */\n isExpired(savedCache: QueryResultCacheOptions): boolean {\n return savedCache.time! + savedCache.duration < Date.now()\n }\n\n /**\n * Stores given query result in the cache.\n */\n async storeInCache(\n options: QueryResultCacheOptions,\n savedCache: QueryResultCacheOptions,\n queryRunner?: QueryRunner,\n ): Promise<void> {\n return new Promise<void>((ok, fail) => {\n if (options.identifier) {\n this.client.set(\n options.identifier,\n JSON.stringify(options),\n \"PX\",\n options.duration,\n (err: any, result: any) => {\n if (err) return fail(err)\n ok()\n },\n )\n } else if (options.query) {\n this.client.set(\n options.query,\n JSON.stringify(options),\n \"PX\",\n options.duration,\n (err: any, result: any) => {\n if (err) return fail(err)\n ok()\n },\n )\n }\n })\n }\n\n /**\n * Clears everything stored in the cache.\n */\n async clear(queryRunner?: QueryRunner): Promise<void> {\n return new Promise<void>((ok, fail) => {\n this.client.flushdb((err: any, result: any) => {\n if (err) return fail(err)\n ok()\n })\n })\n }\n\n /**\n * Removes all cached results by given identifiers from cache.\n */\n async remove(\n identifiers: string[],\n queryRunner?: QueryRunner,\n ): Promise<void> {\n await Promise.all(\n identifiers.map((identifier) => {\n return this.deleteKey(identifier)\n }),\n )\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Removes a single key from redis database.\n */\n protected deleteKey(key: string): Promise<void> {\n return new Promise<void>((ok, fail) => {\n this.client.del(key, (err: any, result: any) => {\n if (err) return fail(err)\n ok()\n })\n })\n }\n\n /**\n * Loads redis dependency.\n */\n protected loadRedis(): any {\n try {\n if (this.clientType === \"ioredis/cluster\") {\n return PlatformTools.load(\"ioredis\")\n } else {\n return PlatformTools.load(this.clientType)\n }\n } catch (e) {\n throw new TypeORMError(\n `Cannot use cache because ${this.clientType} is not installed. Please run \"npm i ${this.clientType} --save\".`,\n )\n }\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/cache/RedisQueryResultCache.ts"],"names":[],"mappings":";;;AAEA,6DAAyD;AAGzD,wDAAoD;AAEpD;;GAEG;AACH,MAAa,qBAAqB;IAyB9B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,UAAsB,EAChC,UAAmD;QADzC,eAAU,GAAV,UAAU,CAAY;QAGhC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;IACjC,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,OAAO;QACT,MAAM,YAAY,GAAQ,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAA;QACvD,IAAI,IAAI,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;YAC9B,MAAM,aAAa,GAAG;gBAClB,GAAG,YAAY,EAAE,OAAO;aAC3B,CAAA;YAED,8CAA8C;YAC9C,IAAI,UAAU,GAAG,IAAI,CAAC,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AC;YACD,IAAI,IAAI,CAAC,UAAU,KAAK,iBAAiB,EAAE,CAAC;gBACxC,OAAO,6BAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YACxC,CAAC;iBAAM,CAAC;gBACJ,OAAO,6BAAa,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YAC9C,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACL,MAAM,IAAI,2BAAY,CAClB,4BAA4B,IAAI,CAAC,UAAU,wCAAwC,IAAI,CAAC,UAAU,IAAI,CACzG,CAAA;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACK,kBAAkB;QACtB,IAAI,IAAI,CAAC,UAAU,KAAK,OAAO;YAAE,OAAM;QAEvC,IAAI,CAAC;YACD,6DAA6D;YAC7D,iDAAiD;YACjD,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAA;YACjC,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACrC,qEAAqE;gBACrE,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACJ,uFAAuF;gBACvF,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAA;YAC9B,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACL,iDAAiD;YACjD,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAA;QAC9B,CAAC;IACL,CAAC;IAED;;OAEG;IACK,gBAAgB;QACpB,IAAI,IAAI,CAAC,UAAU,KAAK,OAAO;YAAE,OAAO,KAAK,CAAA;QAC7C,OAAO,CACH,IAAI,CAAC,iBAAiB,KAAK,SAAS,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,CACtE,CAAA;IACL,CAAC;CACJ;AApUD,sDAoUC","file":"RedisQueryResultCache.js","sourcesContent":["import { QueryResultCache } from \"./QueryResultCache\"\nimport { QueryResultCacheOptions } from \"./QueryResultCacheOptions\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { TypeORMError } from \"../error/TypeORMError\"\n\n/**\n * Caches query result into Redis database.\n */\nexport class RedisQueryResultCache implements QueryResultCache {\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Redis module instance loaded dynamically.\n */\n protected redis: any\n\n /**\n * Connected redis client.\n */\n protected client: any\n\n /**\n * Type of the Redis Client (redis or ioredis).\n */\n protected clientType: \"redis\" | \"ioredis\" | \"ioredis/cluster\"\n\n /**\n * Redis major version number\n */\n protected redisMajorVersion: number | undefined\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected connection: DataSource,\n clientType: \"redis\" | \"ioredis\" | \"ioredis/cluster\",\n ) {\n this.clientType = clientType\n this.redis = this.loadRedis()\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a connection with given cache provider.\n */\n async connect(): Promise<void> {\n const cacheOptions: any = this.connection.options.cache\n if (this.clientType === \"redis\") {\n const clientOptions = {\n ...cacheOptions?.options,\n }\n\n // Create initial client to test Redis version\n let tempClient = this.redis.createClient(clientOptions)\n const isRedis4Plus = typeof tempClient.connect === \"function\"\n\n if (isRedis4Plus) {\n // Redis 4+ detected, recreate with legacyMode for Redis 4.x\n // (Redis 5 will ignore legacyMode if not needed)\n clientOptions.legacyMode = true\n tempClient = this.redis.createClient(clientOptions)\n }\n\n // Set as the main client\n this.client = tempClient\n\n if (\n typeof this.connection.options.cache === \"object\" &&\n this.connection.options.cache.ignoreErrors\n ) {\n this.client.on(\"error\", (err: any) => {\n this.connection.logger.log(\"warn\", err)\n })\n }\n\n // Connect if Redis 4+\n if (typeof this.client.connect === \"function\") {\n await this.client.connect()\n }\n\n // Detect precise version after connection is established\n this.detectRedisVersion()\n } else if (this.clientType === \"ioredis\") {\n if (cacheOptions && cacheOptions.port) {\n if (cacheOptions.options) {\n this.client = new this.redis(\n cacheOptions.port,\n cacheOptions.options,\n )\n } else {\n this.client = new this.redis(cacheOptions.port)\n }\n } else if (cacheOptions && cacheOptions.options) {\n this.client = new this.redis(cacheOptions.options)\n } else {\n this.client = new this.redis()\n }\n } else if (this.clientType === \"ioredis/cluster\") {\n if (\n cacheOptions &&\n cacheOptions.options &&\n Array.isArray(cacheOptions.options)\n ) {\n this.client = new this.redis.Cluster(cacheOptions.options)\n } else if (\n cacheOptions &&\n cacheOptions.options &&\n cacheOptions.options.startupNodes\n ) {\n this.client = new this.redis.Cluster(\n cacheOptions.options.startupNodes,\n cacheOptions.options.options,\n )\n } else {\n throw new TypeORMError(\n `options.startupNodes required for ${this.clientType}.`,\n )\n }\n }\n }\n\n /**\n * Disconnects the connection\n */\n async disconnect(): Promise<void> {\n if (this.isRedis5OrHigher()) {\n // Redis 5+ uses quit() that returns a Promise\n await this.client.quit()\n this.client = undefined\n return\n }\n\n // Redis 3/4 callback style\n return new Promise<void>((ok, fail) => {\n this.client.quit((err: any, result: any) => {\n if (err) return fail(err)\n ok()\n this.client = undefined\n })\n })\n }\n\n /**\n * Creates table for storing cache if it does not exist yet.\n */\n async synchronize(queryRunner: QueryRunner): Promise<void> {}\n\n /**\n * Get data from cache.\n * Returns cache result if found.\n * Returns undefined if result is not cached.\n */\n getFromCache(\n options: QueryResultCacheOptions,\n queryRunner?: QueryRunner,\n ): Promise<QueryResultCacheOptions | undefined> {\n const key = options.identifier || options.query\n if (!key) return Promise.resolve(undefined)\n\n if (this.isRedis5OrHigher()) {\n // Redis 5+ Promise-based API\n return this.client.get(key).then((result: any) => {\n return result ? JSON.parse(result) : undefined\n })\n }\n\n // Redis 3/4 callback-based API\n return new Promise<QueryResultCacheOptions | undefined>((ok, fail) => {\n this.client.get(key, (err: any, result: any) => {\n if (err) return fail(err)\n ok(result ? JSON.parse(result) : undefined)\n })\n })\n }\n\n /**\n * Checks if cache is expired or not.\n */\n isExpired(savedCache: QueryResultCacheOptions): boolean {\n return savedCache.time! + savedCache.duration < Date.now()\n }\n\n /**\n * Stores given query result in the cache.\n */\n async storeInCache(\n options: QueryResultCacheOptions,\n savedCache: QueryResultCacheOptions,\n queryRunner?: QueryRunner,\n ): Promise<void> {\n const key = options.identifier || options.query\n if (!key) return\n\n const value = JSON.stringify(options)\n const duration = options.duration\n\n if (this.isRedis5OrHigher()) {\n // Redis 5+ Promise-based API with PX option\n await this.client.set(key, value, {\n PX: duration,\n })\n return\n }\n\n // Redis 3/4 callback-based API\n return new Promise<void>((ok, fail) => {\n this.client.set(\n key,\n value,\n \"PX\",\n duration,\n (err: any, result: any) => {\n if (err) return fail(err)\n ok()\n },\n )\n })\n }\n\n /**\n * Clears everything stored in the cache.\n */\n async clear(queryRunner?: QueryRunner): Promise<void> {\n if (this.isRedis5OrHigher()) {\n // Redis 5+ Promise-based API\n await this.client.flushDb()\n return\n }\n\n // Redis 3/4 callback-based API\n return new Promise<void>((ok, fail) => {\n this.client.flushdb((err: any, result: any) => {\n if (err) return fail(err)\n ok()\n })\n })\n }\n\n /**\n * Removes all cached results by given identifiers from cache.\n */\n async remove(\n identifiers: string[],\n queryRunner?: QueryRunner,\n ): Promise<void> {\n await Promise.all(\n identifiers.map((identifier) => {\n return this.deleteKey(identifier)\n }),\n )\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Removes a single key from redis database.\n */\n protected async deleteKey(key: string): Promise<void> {\n if (this.isRedis5OrHigher()) {\n // Redis 5+ Promise-based API\n await this.client.del(key)\n return\n }\n\n // Redis 3/4 callback-based API\n return new Promise<void>((ok, fail) => {\n this.client.del(key, (err: any, result: any) => {\n if (err) return fail(err)\n ok()\n })\n })\n }\n\n /**\n * Loads redis dependency.\n */\n protected loadRedis(): any {\n try {\n if (this.clientType === \"ioredis/cluster\") {\n return PlatformTools.load(\"ioredis\")\n } else {\n return PlatformTools.load(this.clientType)\n }\n } catch {\n throw new TypeORMError(\n `Cannot use cache because ${this.clientType} is not installed. Please run \"npm i ${this.clientType}\".`,\n )\n }\n }\n\n /**\n * Detects the Redis version based on the connected client's API characteristics\n * without creating test keys in the database\n */\n private detectRedisVersion(): void {\n if (this.clientType !== \"redis\") return\n\n try {\n // Detect version by examining the client's method signatures\n // This avoids creating test keys in the database\n const setMethod = this.client.set\n if (setMethod && setMethod.length <= 3) {\n // Redis 5+ set method accepts fewer parameters (key, value, options)\n this.redisMajorVersion = 5\n } else {\n // Redis 3/4 set method requires more parameters (key, value, flag, duration, callback)\n this.redisMajorVersion = 3\n }\n } catch {\n // Default to Redis 3/4 for maximum compatibility\n this.redisMajorVersion = 3\n }\n }\n\n /**\n * Checks if Redis version is 5.x or higher\n */\n private isRedis5OrHigher(): boolean {\n if (this.clientType !== \"redis\") return false\n return (\n this.redisMajorVersion !== undefined && this.redisMajorVersion >= 5\n )\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -155,4 +155,10 @@ export interface ColumnOptions extends ColumnCommonOptions {
|
|
|
155
155
|
* SRID (Spatial Reference ID (EPSG code))
|
|
156
156
|
*/
|
|
157
157
|
srid?: number;
|
|
158
|
+
/**
|
|
159
|
+
* Query to be used to populate the column data. This query is used when generating the relational db script.
|
|
160
|
+
* The query function is called with the current entities alias either defined by the Entity Decorator or automatically
|
|
161
|
+
* @See https://typeorm.io/decorator-reference#virtualcolumn for more details.
|
|
162
|
+
*/
|
|
163
|
+
query?: (alias: string) => string;
|
|
158
164
|
}
|
|
@@ -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"],"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 */\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":"../.."}
|
|
@@ -767,7 +767,7 @@ class AuroraMysqlQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
|
|
|
767
767
|
* Drops the columns in the table.
|
|
768
768
|
*/
|
|
769
769
|
async dropColumns(tableOrName, columns) {
|
|
770
|
-
for (const column of columns) {
|
|
770
|
+
for (const column of [...columns]) {
|
|
771
771
|
await this.dropColumn(tableOrName, column);
|
|
772
772
|
}
|
|
773
773
|
}
|