typeorm 0.3.23-dev.45577df → 0.3.23-dev.56f1898
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/driver/mysql/MysqlConnectionOptions.d.ts +6 -0
- package/browser/driver/mysql/MysqlConnectionOptions.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js +6 -1
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/metadata/EntityListenerMetadata.js +14 -2
- package/browser/metadata/EntityListenerMetadata.js.map +1 -1
- package/browser/repository/MongoRepository.d.ts +1 -1
- package/browser/repository/MongoRepository.js.map +1 -1
- package/driver/mysql/MysqlConnectionOptions.d.ts +6 -0
- package/driver/mysql/MysqlConnectionOptions.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.js +6 -1
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/metadata/EntityListenerMetadata.js +14 -2
- package/metadata/EntityListenerMetadata.js.map +1 -1
- package/package.json +1 -1
- package/repository/MongoRepository.d.ts +1 -1
- package/repository/MongoRepository.js.map +1 -1
|
@@ -29,8 +29,20 @@ export class EntityListenerMetadata {
|
|
|
29
29
|
* Executes listener method of the given entity.
|
|
30
30
|
*/
|
|
31
31
|
execute(entity) {
|
|
32
|
-
if
|
|
33
|
-
|
|
32
|
+
// Check if the Embedded Metadata does not exist
|
|
33
|
+
if (!this.embeddedMetadata) {
|
|
34
|
+
// Get the Entity's Method
|
|
35
|
+
const entityMethod = entity[this.propertyName];
|
|
36
|
+
// Check if the Entity Method does not exist
|
|
37
|
+
if (!entityMethod)
|
|
38
|
+
throw new Error(`Entity listener method "${this.propertyName}" does not exist in entity "${entity.constructor.name}".`);
|
|
39
|
+
// Check if the Entity Method is not a function
|
|
40
|
+
if (typeof entityMethod !== "function")
|
|
41
|
+
throw new Error(`Entity listener method "${this.propertyName}" in entity "${entity.constructor.name}" must be a function but got "${typeof entityMethod}".`);
|
|
42
|
+
// Call and return the Entity Method
|
|
43
|
+
return entityMethod.call(entity);
|
|
44
|
+
}
|
|
45
|
+
// Call the Embedded Method
|
|
34
46
|
this.callEntityEmbeddedMethod(entity, this.embeddedMetadata.propertyPath.split("."));
|
|
35
47
|
}
|
|
36
48
|
// ---------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/metadata/EntityListenerMetadata.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,sBAAsB;IA+B/B,wEAAwE;IACxE,cAAc;IACd,wEAAwE;IAExE,YAAY,OAIX;QACG,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAA;QAChD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAA;QACjC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,CAAA;QAC7C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA;IACjC,CAAC;IAED,wEAAwE;IACxE,iBAAiB;IACjB,wEAAwE;IAExE;;OAEG;IACH,SAAS,CAAC,MAAqB;QAC3B,2DAA2D;QAC3D,OAAO,CACH,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,MAAM,CAAC,WAAW,IAAI,oIAAoI;YACzL,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,UAAU;gBAC7C,MAAM,CAAC,WAAW,CAAC,SAAS;oBACxB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CACtC,CAAA,CAAC,yDAAyD;IAC/D,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,MAAqB;QACzB,IAAI,CAAC,IAAI,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"sources":["../browser/src/metadata/EntityListenerMetadata.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,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IACvB,iCAAiC,OAAO,YAAY,IAAI,CAC3D,CAAA;YAEL,oCAAoC;YACpC,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACpC,CAAC;QAED,2BAA2B;QAC3B,IAAI,CAAC,wBAAwB,CACzB,MAAM,EACN,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAChD,CAAA;IACL,CAAC;IAED,wEAAwE;IACxE,oBAAoB;IACpB,wEAAwE;IAExE;;OAEG;IACO,wBAAwB,CAC9B,MAAqB,EACrB,aAAuB;QAEvB,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,EAAE,CAAA;QAC1C,IAAI,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YAAE,OAAM;QAElD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;gBACtC,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,QAAuB,EAAE,EAAE,CACjD,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAChC,CAAA;YACL,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAA;YAC7C,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,MAAM,CAAC,YAAY,CAAC;gBACpB,IAAI,CAAC,wBAAwB,CACzB,MAAM,CAAC,YAAY,CAAC,EACpB,aAAa,CAChB,CAAA;QACT,CAAC;IACL,CAAC;CACJ","file":"EntityListenerMetadata.js","sourcesContent":["import { EventListenerType } from \"./types/EventListenerTypes\"\nimport { EntityListenerMetadataArgs } from \"../metadata-args/EntityListenerMetadataArgs\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { EntityMetadata } from \"./EntityMetadata\"\nimport { EmbeddedMetadata } from \"./EmbeddedMetadata\"\n\n/**\n * This metadata contains all information about entity's listeners.\n */\nexport class EntityListenerMetadata {\n // ---------------------------------------------------------------------\n // Properties\n // ---------------------------------------------------------------------\n\n /**\n * Entity metadata of the listener.\n */\n entityMetadata: EntityMetadata\n\n /**\n * Embedded metadata of the listener, in the case if listener is in embedded.\n */\n embeddedMetadata?: EmbeddedMetadata\n\n /**\n * Target class to which metadata is applied.\n * This can be different then entityMetadata.target in the case if listener is in the embedded.\n */\n target: Function | string\n\n /**\n * Target's property name to which this metadata is applied.\n */\n propertyName: string\n\n /**\n * The type of the listener.\n */\n type: EventListenerType\n\n // ---------------------------------------------------------------------\n // Constructor\n // ---------------------------------------------------------------------\n\n constructor(options: {\n entityMetadata: EntityMetadata\n embeddedMetadata?: EmbeddedMetadata\n args: EntityListenerMetadataArgs\n }) {\n this.entityMetadata = options.entityMetadata\n this.embeddedMetadata = options.embeddedMetadata\n this.target = options.args.target\n this.propertyName = options.args.propertyName\n this.type = options.args.type\n }\n\n // ---------------------------------------------------------------------\n // Public Methods\n // ---------------------------------------------------------------------\n\n /**\n * Checks if entity listener is allowed to be executed on the given entity.\n */\n isAllowed(entity: ObjectLiteral) {\n // todo: create in entity metadata method like isInherited?\n return (\n this.entityMetadata.target === entity.constructor || // todo: .constructor won't work for entity schemas, but there are no entity listeners in schemas since there are no objects, right?\n (typeof this.entityMetadata.target === \"function\" &&\n entity.constructor.prototype instanceof\n this.entityMetadata.target)\n ) // todo: also need to implement entity schema inheritance\n }\n\n /**\n * Executes listener method of the given entity.\n */\n execute(entity: ObjectLiteral) {\n // Check if the Embedded Metadata does not exist\n if (!this.embeddedMetadata) {\n // Get the Entity's Method\n const entityMethod = entity[this.propertyName]\n\n // Check if the Entity Method does not exist\n if (!entityMethod)\n throw new Error(\n `Entity listener method \"${this.propertyName}\" does not exist in entity \"${entity.constructor.name}\".`,\n )\n\n // Check if the Entity Method is not a function\n if (typeof entityMethod !== \"function\")\n throw new Error(\n `Entity listener method \"${this.propertyName}\" in entity \"${\n entity.constructor.name\n }\" must be a function but got \"${typeof entityMethod}\".`,\n )\n\n // Call and return the Entity Method\n return entityMethod.call(entity)\n }\n\n // Call the Embedded Method\n this.callEntityEmbeddedMethod(\n entity,\n this.embeddedMetadata.propertyPath.split(\".\"),\n )\n }\n\n // ---------------------------------------------------------------------\n // Protected Methods\n // ---------------------------------------------------------------------\n\n /**\n * Calls embedded entity listener method no matter how nested it is.\n */\n protected callEntityEmbeddedMethod(\n entity: ObjectLiteral,\n propertyPaths: string[],\n ): void {\n const propertyPath = propertyPaths.shift()\n if (!propertyPath || !entity[propertyPath]) return\n\n if (propertyPaths.length === 0) {\n if (Array.isArray(entity[propertyPath])) {\n entity[propertyPath].map((embedded: ObjectLiteral) =>\n embedded[this.propertyName](),\n )\n } else {\n entity[propertyPath][this.propertyName]()\n }\n } else {\n if (entity[propertyPath])\n this.callEntityEmbeddedMethod(\n entity[propertyPath],\n propertyPaths,\n )\n }\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -97,7 +97,7 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
|
|
|
97
97
|
/**
|
|
98
98
|
* Execute an aggregation framework pipeline against the collection.
|
|
99
99
|
*/
|
|
100
|
-
aggregate<R = any>(pipeline: ObjectLiteral[], options?: AggregateOptions): AggregationCursor<
|
|
100
|
+
aggregate<R = any>(pipeline: ObjectLiteral[], options?: AggregateOptions): AggregationCursor<R>;
|
|
101
101
|
/**
|
|
102
102
|
* Execute an aggregation framework pipeline against the collection.
|
|
103
103
|
* This returns modified version of cursor that transforms each result into Entity model.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/repository/MongoRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAKzC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AA2CpD;;GAEG;AACH,MAAM,OAAO,eAEX,SAAQ,UAAkB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MongoRepository.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { Repository } from \"./Repository\"\nimport { MongoFindManyOptions } from \"../find-options/mongodb/MongoFindManyOptions\"\nimport { MongoEntityManager } from \"../entity-manager/MongoEntityManager\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { TypeORMError } from \"../error/TypeORMError\"\nimport { MongoFindOneOptions } from \"../find-options/mongodb/MongoFindOneOptions\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\n\nimport {\n CreateIndexesOptions,\n ObjectId,\n ReplaceOptions,\n //\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BulkWriteOptions,\n BulkWriteResult,\n Collection,\n CollStats,\n CollStatsOptions,\n CommandOperationOptions,\n CountOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n Filter,\n FilterOperators,\n FindCursor,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n IndexDescription,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListIndexesOptions,\n OrderedBulkOperation,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n CountDocumentsOptions,\n} from \"../driver/mongodb/typings\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\n\n/**\n * Repository used to manage mongodb documents of a single entity type.\n */\nexport class MongoRepository<\n Entity extends ObjectLiteral,\n> extends Repository<Entity> {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: MongoEntityManager\n\n // -------------------------------------------------------------------------\n // Overridden Methods\n // -------------------------------------------------------------------------\n\n /**\n * Raw SQL query execution is not supported by MongoDB.\n * Calling this method will return an error.\n */\n query(query: string, parameters?: any[]): Promise<any> {\n throw new TypeORMError(`Queries aren't supported by MongoDB.`)\n }\n\n /**\n * Using Query Builder with MongoDB is not supported yet.\n * Calling this method will return an error.\n */\n createQueryBuilder(\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n throw new TypeORMError(`Query Builder is not supported by MongoDB.`)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(\n options?:\n | FindManyOptions<Entity>\n | Partial<Entity>\n | FilterOperators<Entity>,\n ): Promise<Entity[]> {\n return this.manager.find(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n */\n findBy(where: any): Promise<Entity[]> {\n return this.manager.findBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(\n options?: MongoFindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n return this.manager.findAndCount(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy(where: any): Promise<[Entity[], number]> {\n return this.manager.findAndCountBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n findByIds(ids: any[], options?: any): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target, ids, options)\n }\n\n /**\n * Finds first entity that matches given find options.\n */\n async findOne(\n options: MongoFindOneOptions<Entity>,\n ): Promise<Entity | null> {\n return this.manager.findOne(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given WHERE conditions.\n */\n async findOneBy(where: any): Promise<Entity | null> {\n return this.manager.findOneBy(this.metadata.target, where)\n }\n\n /**\n * Finds entity that matches given id.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById(\n id: string | number | Date | ObjectId,\n ): Promise<Entity | null> {\n return this.manager.findOneById(this.metadata.target, id)\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail(options: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail(where: any): Promise<Entity> {\n return this.manager.findOneByOrFail(this.metadata.target, where)\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n */\n createCursor<T = any>(query?: Filter<Entity>): FindCursor<T> {\n return this.manager.createCursor(this.metadata.target, query)\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n * This returns modified version of cursor that transforms each result into Entity model.\n */\n createEntityCursor(query?: Filter<Entity>): FindCursor<Entity> {\n return this.manager.createEntityCursor(this.metadata.target, query)\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n */\n aggregate<R = any>(\n pipeline: ObjectLiteral[],\n options?: AggregateOptions,\n ): AggregationCursor<Entity> {\n return this.manager.aggregate<R>(\n this.metadata.target,\n pipeline,\n options,\n )\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n * This returns modified version of cursor that transforms each result into Entity model.\n */\n aggregateEntity(\n pipeline: ObjectLiteral[],\n options?: AggregateOptions,\n ): AggregationCursor<Entity> {\n return this.manager.aggregateEntity(\n this.metadata.target,\n pipeline,\n options,\n )\n }\n /**\n * Perform a bulkWrite operation without a fluent API.\n */\n bulkWrite(\n operations: AnyBulkWriteOperation[],\n options?: BulkWriteOptions,\n ): Promise<BulkWriteResult> {\n return this.manager.bulkWrite(this.metadata.target, operations, options)\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n count(query?: ObjectLiteral, options?: CountOptions): Promise<number> {\n return this.manager.count(this.metadata.target, query || {}, options)\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n countDocuments(\n query?: ObjectLiteral,\n options?: CountDocumentsOptions,\n ): Promise<number> {\n return this.manager.countDocuments(\n this.metadata.target,\n query || {},\n options,\n )\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n countBy(query?: ObjectLiteral, options?: CountOptions): Promise<number> {\n return this.manager.countBy(this.metadata.target, query, options)\n }\n\n /**\n * Creates an index on the db and collection.\n */\n createCollectionIndex(\n fieldOrSpec: string | any,\n options?: CreateIndexesOptions,\n ): Promise<string> {\n return this.manager.createCollectionIndex(\n this.metadata.target,\n fieldOrSpec,\n options,\n )\n }\n\n /**\n * Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.\n * Earlier version of MongoDB will throw a command not supported error.\n * Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.\n */\n createCollectionIndexes(indexSpecs: IndexDescription[]): Promise<string[]> {\n return this.manager.createCollectionIndexes(\n this.metadata.target,\n indexSpecs,\n )\n }\n\n /**\n * Delete multiple documents on MongoDB.\n */\n deleteMany(\n query: ObjectLiteral,\n options?: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.manager.deleteMany(this.metadata.tableName, query, options)\n }\n\n /**\n * Delete a document on MongoDB.\n */\n deleteOne(\n query: ObjectLiteral,\n options?: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.manager.deleteOne(this.metadata.tableName, query, options)\n }\n\n /**\n * The distinct command returns returns a list of distinct values for the given key across a collection.\n */\n distinct(\n key: string,\n query: ObjectLiteral,\n options?: CommandOperationOptions,\n ): Promise<any> {\n return this.manager.distinct(\n this.metadata.tableName,\n key,\n query,\n options,\n )\n }\n\n /**\n * Drops an index from this collection.\n */\n dropCollectionIndex(\n indexName: string,\n options?: CommandOperationOptions,\n ): Promise<any> {\n return this.manager.dropCollectionIndex(\n this.metadata.tableName,\n indexName,\n options,\n )\n }\n\n /**\n * Drops all indexes from the collection.\n */\n dropCollectionIndexes(): Promise<any> {\n return this.manager.dropCollectionIndexes(this.metadata.tableName)\n }\n\n /**\n * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndDelete(\n query: ObjectLiteral,\n options?: FindOneAndDeleteOptions,\n ): Promise<Document | null> {\n return this.manager.findOneAndDelete(\n this.metadata.tableName,\n query,\n options,\n )\n }\n\n /**\n * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndReplace(\n query: ObjectLiteral,\n replacement: Object,\n options?: FindOneAndReplaceOptions,\n ): Promise<Document | null> {\n return this.manager.findOneAndReplace(\n this.metadata.tableName,\n query,\n replacement,\n options,\n )\n }\n\n /**\n * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndUpdate(\n query: ObjectLiteral,\n update: Object,\n options?: FindOneAndUpdateOptions,\n ): Promise<Document | null> {\n return this.manager.findOneAndUpdate(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n collectionIndexes(): Promise<any> {\n return this.manager.collectionIndexes(this.metadata.tableName)\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n collectionIndexExists(indexes: string | string[]): Promise<boolean> {\n return this.manager.collectionIndexExists(\n this.metadata.tableName,\n indexes,\n )\n }\n\n /**\n * Retrieves this collections index info.\n */\n collectionIndexInformation(options?: { full: boolean }): Promise<any> {\n return this.manager.collectionIndexInformation(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.\n */\n initializeOrderedBulkOp(options?: BulkWriteOptions): OrderedBulkOperation {\n return this.manager.initializeOrderedBulkOp(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.\n */\n initializeUnorderedBulkOp(\n options?: BulkWriteOptions,\n ): UnorderedBulkOperation {\n return this.manager.initializeUnorderedBulkOp(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Inserts an array of documents into MongoDB.\n */\n insertMany(\n docs: ObjectLiteral[],\n options?: BulkWriteOptions,\n ): Promise<InsertManyResult<Document>> {\n return this.manager.insertMany(this.metadata.tableName, docs, options)\n }\n\n /**\n * Inserts a single document into MongoDB.\n */\n insertOne(\n doc: ObjectLiteral,\n options?: InsertOneOptions,\n ): Promise<InsertOneResult> {\n return this.manager.insertOne(this.metadata.tableName, doc, options)\n }\n\n /**\n * Returns if the collection is a capped collection.\n */\n isCapped(): Promise<any> {\n return this.manager.isCapped(this.metadata.tableName)\n }\n\n /**\n * Get the list of all indexes information for the collection.\n */\n listCollectionIndexes(options?: ListIndexesOptions): ListIndexesCursor {\n return this.manager.listCollectionIndexes(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.\n */\n rename(\n newName: string,\n options?: { dropTarget?: boolean },\n ): Promise<Collection<Document>> {\n return this.manager.rename(this.metadata.tableName, newName, options)\n }\n\n /**\n * Replace a document on MongoDB.\n */\n replaceOne(\n query: ObjectLiteral,\n doc: ObjectLiteral,\n options?: ReplaceOptions,\n ): Promise<Document | UpdateResult> {\n return this.manager.replaceOne(\n this.metadata.tableName,\n query,\n doc,\n options,\n )\n }\n\n /**\n * Get all the collection statistics.\n */\n stats(options?: CollStatsOptions): Promise<CollStats> {\n return this.manager.stats(this.metadata.tableName, options)\n }\n\n /**\n * Update multiple documents on MongoDB.\n */\n updateMany(\n query: ObjectLiteral,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return this.manager.updateMany(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n\n /**\n * Update a single document on MongoDB.\n */\n updateOne(\n query: ObjectLiteral,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return this.manager.updateOne(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/repository/MongoR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ACpB,MAA8B,EAC9B,OAAuB;QAEvB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CACzB,IAAI,CAAC,QAAQ,CAAC,SAAS,EACvB,KAAK,EACL,MAAM,EACN,OAAO,CACV,CAAA;IACL,CAAC;CACJ","file":"MongoRepository.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { Repository } from \"./Repository\"\nimport { MongoFindManyOptions } from \"../find-options/mongodb/MongoFindManyOptions\"\nimport { MongoEntityManager } from \"../entity-manager/MongoEntityManager\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { TypeORMError } from \"../error/TypeORMError\"\nimport { MongoFindOneOptions } from \"../find-options/mongodb/MongoFindOneOptions\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\n\nimport {\n CreateIndexesOptions,\n ObjectId,\n ReplaceOptions,\n //\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BulkWriteOptions,\n BulkWriteResult,\n Collection,\n CollStats,\n CollStatsOptions,\n CommandOperationOptions,\n CountOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n Filter,\n FilterOperators,\n FindCursor,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n IndexDescription,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListIndexesOptions,\n OrderedBulkOperation,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n CountDocumentsOptions,\n} from \"../driver/mongodb/typings\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\n\n/**\n * Repository used to manage mongodb documents of a single entity type.\n */\nexport class MongoRepository<\n Entity extends ObjectLiteral,\n> extends Repository<Entity> {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: MongoEntityManager\n\n // -------------------------------------------------------------------------\n // Overridden Methods\n // -------------------------------------------------------------------------\n\n /**\n * Raw SQL query execution is not supported by MongoDB.\n * Calling this method will return an error.\n */\n query(query: string, parameters?: any[]): Promise<any> {\n throw new TypeORMError(`Queries aren't supported by MongoDB.`)\n }\n\n /**\n * Using Query Builder with MongoDB is not supported yet.\n * Calling this method will return an error.\n */\n createQueryBuilder(\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n throw new TypeORMError(`Query Builder is not supported by MongoDB.`)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(\n options?:\n | FindManyOptions<Entity>\n | Partial<Entity>\n | FilterOperators<Entity>,\n ): Promise<Entity[]> {\n return this.manager.find(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n */\n findBy(where: any): Promise<Entity[]> {\n return this.manager.findBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(\n options?: MongoFindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n return this.manager.findAndCount(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy(where: any): Promise<[Entity[], number]> {\n return this.manager.findAndCountBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n findByIds(ids: any[], options?: any): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target, ids, options)\n }\n\n /**\n * Finds first entity that matches given find options.\n */\n async findOne(\n options: MongoFindOneOptions<Entity>,\n ): Promise<Entity | null> {\n return this.manager.findOne(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given WHERE conditions.\n */\n async findOneBy(where: any): Promise<Entity | null> {\n return this.manager.findOneBy(this.metadata.target, where)\n }\n\n /**\n * Finds entity that matches given id.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById(\n id: string | number | Date | ObjectId,\n ): Promise<Entity | null> {\n return this.manager.findOneById(this.metadata.target, id)\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail(options: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail(where: any): Promise<Entity> {\n return this.manager.findOneByOrFail(this.metadata.target, where)\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n */\n createCursor<T = any>(query?: Filter<Entity>): FindCursor<T> {\n return this.manager.createCursor(this.metadata.target, query)\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n * This returns modified version of cursor that transforms each result into Entity model.\n */\n createEntityCursor(query?: Filter<Entity>): FindCursor<Entity> {\n return this.manager.createEntityCursor(this.metadata.target, query)\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n */\n aggregate<R = any>(\n pipeline: ObjectLiteral[],\n options?: AggregateOptions,\n ): AggregationCursor<R> {\n return this.manager.aggregate<R>(\n this.metadata.target,\n pipeline,\n options,\n )\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n * This returns modified version of cursor that transforms each result into Entity model.\n */\n aggregateEntity(\n pipeline: ObjectLiteral[],\n options?: AggregateOptions,\n ): AggregationCursor<Entity> {\n return this.manager.aggregateEntity(\n this.metadata.target,\n pipeline,\n options,\n )\n }\n /**\n * Perform a bulkWrite operation without a fluent API.\n */\n bulkWrite(\n operations: AnyBulkWriteOperation[],\n options?: BulkWriteOptions,\n ): Promise<BulkWriteResult> {\n return this.manager.bulkWrite(this.metadata.target, operations, options)\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n count(query?: ObjectLiteral, options?: CountOptions): Promise<number> {\n return this.manager.count(this.metadata.target, query || {}, options)\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n countDocuments(\n query?: ObjectLiteral,\n options?: CountDocumentsOptions,\n ): Promise<number> {\n return this.manager.countDocuments(\n this.metadata.target,\n query || {},\n options,\n )\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n countBy(query?: ObjectLiteral, options?: CountOptions): Promise<number> {\n return this.manager.countBy(this.metadata.target, query, options)\n }\n\n /**\n * Creates an index on the db and collection.\n */\n createCollectionIndex(\n fieldOrSpec: string | any,\n options?: CreateIndexesOptions,\n ): Promise<string> {\n return this.manager.createCollectionIndex(\n this.metadata.target,\n fieldOrSpec,\n options,\n )\n }\n\n /**\n * Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.\n * Earlier version of MongoDB will throw a command not supported error.\n * Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.\n */\n createCollectionIndexes(indexSpecs: IndexDescription[]): Promise<string[]> {\n return this.manager.createCollectionIndexes(\n this.metadata.target,\n indexSpecs,\n )\n }\n\n /**\n * Delete multiple documents on MongoDB.\n */\n deleteMany(\n query: ObjectLiteral,\n options?: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.manager.deleteMany(this.metadata.tableName, query, options)\n }\n\n /**\n * Delete a document on MongoDB.\n */\n deleteOne(\n query: ObjectLiteral,\n options?: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.manager.deleteOne(this.metadata.tableName, query, options)\n }\n\n /**\n * The distinct command returns returns a list of distinct values for the given key across a collection.\n */\n distinct(\n key: string,\n query: ObjectLiteral,\n options?: CommandOperationOptions,\n ): Promise<any> {\n return this.manager.distinct(\n this.metadata.tableName,\n key,\n query,\n options,\n )\n }\n\n /**\n * Drops an index from this collection.\n */\n dropCollectionIndex(\n indexName: string,\n options?: CommandOperationOptions,\n ): Promise<any> {\n return this.manager.dropCollectionIndex(\n this.metadata.tableName,\n indexName,\n options,\n )\n }\n\n /**\n * Drops all indexes from the collection.\n */\n dropCollectionIndexes(): Promise<any> {\n return this.manager.dropCollectionIndexes(this.metadata.tableName)\n }\n\n /**\n * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndDelete(\n query: ObjectLiteral,\n options?: FindOneAndDeleteOptions,\n ): Promise<Document | null> {\n return this.manager.findOneAndDelete(\n this.metadata.tableName,\n query,\n options,\n )\n }\n\n /**\n * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndReplace(\n query: ObjectLiteral,\n replacement: Object,\n options?: FindOneAndReplaceOptions,\n ): Promise<Document | null> {\n return this.manager.findOneAndReplace(\n this.metadata.tableName,\n query,\n replacement,\n options,\n )\n }\n\n /**\n * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndUpdate(\n query: ObjectLiteral,\n update: Object,\n options?: FindOneAndUpdateOptions,\n ): Promise<Document | null> {\n return this.manager.findOneAndUpdate(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n collectionIndexes(): Promise<any> {\n return this.manager.collectionIndexes(this.metadata.tableName)\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n collectionIndexExists(indexes: string | string[]): Promise<boolean> {\n return this.manager.collectionIndexExists(\n this.metadata.tableName,\n indexes,\n )\n }\n\n /**\n * Retrieves this collections index info.\n */\n collectionIndexInformation(options?: { full: boolean }): Promise<any> {\n return this.manager.collectionIndexInformation(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.\n */\n initializeOrderedBulkOp(options?: BulkWriteOptions): OrderedBulkOperation {\n return this.manager.initializeOrderedBulkOp(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.\n */\n initializeUnorderedBulkOp(\n options?: BulkWriteOptions,\n ): UnorderedBulkOperation {\n return this.manager.initializeUnorderedBulkOp(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Inserts an array of documents into MongoDB.\n */\n insertMany(\n docs: ObjectLiteral[],\n options?: BulkWriteOptions,\n ): Promise<InsertManyResult<Document>> {\n return this.manager.insertMany(this.metadata.tableName, docs, options)\n }\n\n /**\n * Inserts a single document into MongoDB.\n */\n insertOne(\n doc: ObjectLiteral,\n options?: InsertOneOptions,\n ): Promise<InsertOneResult> {\n return this.manager.insertOne(this.metadata.tableName, doc, options)\n }\n\n /**\n * Returns if the collection is a capped collection.\n */\n isCapped(): Promise<any> {\n return this.manager.isCapped(this.metadata.tableName)\n }\n\n /**\n * Get the list of all indexes information for the collection.\n */\n listCollectionIndexes(options?: ListIndexesOptions): ListIndexesCursor {\n return this.manager.listCollectionIndexes(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.\n */\n rename(\n newName: string,\n options?: { dropTarget?: boolean },\n ): Promise<Collection<Document>> {\n return this.manager.rename(this.metadata.tableName, newName, options)\n }\n\n /**\n * Replace a document on MongoDB.\n */\n replaceOne(\n query: ObjectLiteral,\n doc: ObjectLiteral,\n options?: ReplaceOptions,\n ): Promise<Document | UpdateResult> {\n return this.manager.replaceOne(\n this.metadata.tableName,\n query,\n doc,\n options,\n )\n }\n\n /**\n * Get all the collection statistics.\n */\n stats(options?: CollStatsOptions): Promise<CollStats> {\n return this.manager.stats(this.metadata.tableName, options)\n }\n\n /**\n * Update multiple documents on MongoDB.\n */\n updateMany(\n query: ObjectLiteral,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return this.manager.updateMany(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n\n /**\n * Update a single document on MongoDB.\n */\n updateOne(\n query: ObjectLiteral,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return this.manager.updateOne(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -90,6 +90,12 @@ export interface MysqlConnectionOptions extends BaseDataSourceOptions, MysqlConn
|
|
|
90
90
|
* but you can specify it manually
|
|
91
91
|
*/
|
|
92
92
|
readonly connectorPackage?: "mysql" | "mysql2";
|
|
93
|
+
/**
|
|
94
|
+
* If a value is specified for maxQueryExecutionTime, in addition to generating a warning log when a query exceeds this time limit,
|
|
95
|
+
* the specified maxQueryExecutionTime value is also used as the timeout for the query.
|
|
96
|
+
* For more information, check https://github.com/mysqljs/mysql?tab=readme-ov-file#timeouts
|
|
97
|
+
*/
|
|
98
|
+
readonly enableQueryTimeout?: boolean;
|
|
93
99
|
/**
|
|
94
100
|
* Replication setup.
|
|
95
101
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/driver/mysql/MysqlConnectionOptions.ts"],"names":[],"mappings":"","file":"MysqlConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\nimport { MysqlConnectionCredentialsOptions } from \"./MysqlConnectionCredentialsOptions\"\n\n/**\n * MySQL specific connection options.\n *\n * @see https://github.com/mysqljs/mysql#connection-options\n */\nexport interface MysqlConnectionOptions\n extends BaseDataSourceOptions,\n MysqlConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"mysql\" | \"mariadb\"\n\n /**\n * The driver object\n * This defaults to require(\"mysql\").\n * Falls back to require(\"mysql2\")\n */\n readonly driver?: any\n\n /**\n * The charset for the connection. This is called \"collation\" in the SQL-level of MySQL (like utf8_general_ci).\n * If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used.\n * Default: 'UTF8_GENERAL_CI'\n */\n readonly charset?: string\n\n /**\n * The timezone configured on the MySQL server.\n * This is used to type cast server date/time values to JavaScript Date object and vice versa.\n * This can be 'local', 'Z', or an offset in the form +HH:MM or -HH:MM. (Default: 'local')\n */\n readonly timezone?: string\n\n /**\n * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10000)\n */\n readonly connectTimeout?: number\n\n /**\n * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10000)\n * This difference between connectTimeout and acquireTimeout is subtle and is described in the mysqljs/mysql docs\n * https://github.com/mysqljs/mysql/tree/master#pool-options\n */\n readonly acquireTimeout?: number\n\n /**\n * Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)\n */\n readonly insecureAuth?: boolean\n\n /**\n * When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option (Default: false)\n */\n readonly supportBigNumbers?: boolean\n\n /**\n * Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be always\n * returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving bigNumberStrings\n * disabled will return big numbers as String objects only when they cannot be accurately represented with\n * [JavaScript Number objects](http://ecma262-5.com/ELS5_HTML.htm#Section_8.5) (which happens when they exceed the [-2^53, +2^53] range),\n * otherwise they will be returned as Number objects. This option is ignored if supportBigNumbers is disabled.\n */\n readonly bigNumberStrings?: boolean\n\n /**\n * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date objects.\n * Can be true/false or an array of type names to keep as strings.\n */\n readonly dateStrings?: boolean | string[]\n\n /**\n * Prints protocol details to stdout. Can be true/false or an array of packet type names that should be printed.\n * (Default: false)\n */\n readonly debug?: boolean | string[]\n\n /**\n * Generates stack traces on Error to include call site of library entrance (\"long stack traces\").\n * Slight performance penalty for most calls. (Default: true)\n */\n readonly trace?: boolean\n\n /**\n * Allow multiple mysql statements per query. Be careful with this, it could increase the scope of SQL injection attacks.\n * (Default: false)\n */\n readonly multipleStatements?: boolean\n\n /**\n * Use spatial functions like GeomFromText and AsText which are removed in MySQL 8.\n * (Default: true)\n */\n readonly legacySpatialSupport?: boolean\n\n /**\n * List of connection flags to use other than the default ones. It is also possible to blacklist default ones.\n * For more information, check https://github.com/mysqljs/mysql#connection-flags.\n */\n readonly flags?: string[]\n\n /**\n * TypeORM will automatically use package found in your node_modules, prioritizing mysql over mysql2,\n * but you can specify it manually\n */\n readonly connectorPackage?: \"mysql\" | \"mysql2\"\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: MysqlConnectionCredentialsOptions\n\n /**\n * List of read-from servers (slaves).\n */\n readonly slaves: MysqlConnectionCredentialsOptions[]\n\n /**\n * If true, PoolCluster will attempt to reconnect when connection fails. (Default: true)\n */\n readonly canRetry?: boolean\n\n /**\n * If connection fails, node's errorCount increases.\n * When errorCount is greater than removeNodeErrorCount, remove a node in the PoolCluster. (Default: 5)\n */\n readonly removeNodeErrorCount?: number\n\n /**\n * If connection fails, specifies the number of milliseconds before another connection attempt will be made.\n * If set to 0, then node will be removed instead and never re-used. (Default: 0)\n */\n readonly restoreNodeTimeout?: number\n\n /**\n * Determines how slaves are selected:\n * RR: Select one alternately (Round-Robin).\n * RANDOM: Select the node by random function.\n * ORDER: Select the first node available unconditionally.\n */\n readonly selector?: \"RR\" | \"RANDOM\" | \"ORDER\"\n\n /**\n * Default connection pool to use for SELECT queries\n * @default \"slave\"\n */\n readonly defaultMode?: ReplicationMode\n }\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/driver/mysql/MysqlConnectionOptions.ts"],"names":[],"mappings":"","file":"MysqlConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\nimport { MysqlConnectionCredentialsOptions } from \"./MysqlConnectionCredentialsOptions\"\n\n/**\n * MySQL specific connection options.\n *\n * @see https://github.com/mysqljs/mysql#connection-options\n */\nexport interface MysqlConnectionOptions\n extends BaseDataSourceOptions,\n MysqlConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"mysql\" | \"mariadb\"\n\n /**\n * The driver object\n * This defaults to require(\"mysql\").\n * Falls back to require(\"mysql2\")\n */\n readonly driver?: any\n\n /**\n * The charset for the connection. This is called \"collation\" in the SQL-level of MySQL (like utf8_general_ci).\n * If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used.\n * Default: 'UTF8_GENERAL_CI'\n */\n readonly charset?: string\n\n /**\n * The timezone configured on the MySQL server.\n * This is used to type cast server date/time values to JavaScript Date object and vice versa.\n * This can be 'local', 'Z', or an offset in the form +HH:MM or -HH:MM. (Default: 'local')\n */\n readonly timezone?: string\n\n /**\n * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10000)\n */\n readonly connectTimeout?: number\n\n /**\n * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10000)\n * This difference between connectTimeout and acquireTimeout is subtle and is described in the mysqljs/mysql docs\n * https://github.com/mysqljs/mysql/tree/master#pool-options\n */\n readonly acquireTimeout?: number\n\n /**\n * Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)\n */\n readonly insecureAuth?: boolean\n\n /**\n * When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option (Default: false)\n */\n readonly supportBigNumbers?: boolean\n\n /**\n * Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be always\n * returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving bigNumberStrings\n * disabled will return big numbers as String objects only when they cannot be accurately represented with\n * [JavaScript Number objects](http://ecma262-5.com/ELS5_HTML.htm#Section_8.5) (which happens when they exceed the [-2^53, +2^53] range),\n * otherwise they will be returned as Number objects. This option is ignored if supportBigNumbers is disabled.\n */\n readonly bigNumberStrings?: boolean\n\n /**\n * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date objects.\n * Can be true/false or an array of type names to keep as strings.\n */\n readonly dateStrings?: boolean | string[]\n\n /**\n * Prints protocol details to stdout. Can be true/false or an array of packet type names that should be printed.\n * (Default: false)\n */\n readonly debug?: boolean | string[]\n\n /**\n * Generates stack traces on Error to include call site of library entrance (\"long stack traces\").\n * Slight performance penalty for most calls. (Default: true)\n */\n readonly trace?: boolean\n\n /**\n * Allow multiple mysql statements per query. Be careful with this, it could increase the scope of SQL injection attacks.\n * (Default: false)\n */\n readonly multipleStatements?: boolean\n\n /**\n * Use spatial functions like GeomFromText and AsText which are removed in MySQL 8.\n * (Default: true)\n */\n readonly legacySpatialSupport?: boolean\n\n /**\n * List of connection flags to use other than the default ones. It is also possible to blacklist default ones.\n * For more information, check https://github.com/mysqljs/mysql#connection-flags.\n */\n readonly flags?: string[]\n\n /**\n * TypeORM will automatically use package found in your node_modules, prioritizing mysql over mysql2,\n * but you can specify it manually\n */\n readonly connectorPackage?: \"mysql\" | \"mysql2\"\n\n /**\n * If a value is specified for maxQueryExecutionTime, in addition to generating a warning log when a query exceeds this time limit,\n * the specified maxQueryExecutionTime value is also used as the timeout for the query.\n * For more information, check https://github.com/mysqljs/mysql?tab=readme-ov-file#timeouts\n */\n readonly enableQueryTimeout?: boolean\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: MysqlConnectionCredentialsOptions\n\n /**\n * List of read-from servers (slaves).\n */\n readonly slaves: MysqlConnectionCredentialsOptions[]\n\n /**\n * If true, PoolCluster will attempt to reconnect when connection fails. (Default: true)\n */\n readonly canRetry?: boolean\n\n /**\n * If connection fails, node's errorCount increases.\n * When errorCount is greater than removeNodeErrorCount, remove a node in the PoolCluster. (Default: 5)\n */\n readonly removeNodeErrorCount?: number\n\n /**\n * If connection fails, specifies the number of milliseconds before another connection attempt will be made.\n * If set to 0, then node will be removed instead and never re-used. (Default: 0)\n */\n readonly restoreNodeTimeout?: number\n\n /**\n * Determines how slaves are selected:\n * RR: Select one alternately (Round-Robin).\n * RANDOM: Select the node by random function.\n * ORDER: Select the first node available unconditionally.\n */\n readonly selector?: \"RR\" | \"RANDOM\" | \"ORDER\"\n\n /**\n * Default connection pool to use for SELECT queries\n * @default \"slave\"\n */\n readonly defaultMode?: ReplicationMode\n }\n}\n"],"sourceRoot":"../.."}
|
|
@@ -147,8 +147,13 @@ class MysqlQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
|
|
|
147
147
|
const databaseConnection = await this.connect();
|
|
148
148
|
this.driver.connection.logger.logQuery(query, parameters, this);
|
|
149
149
|
this.broadcaster.broadcastBeforeQueryEvent(broadcasterResult, query, parameters);
|
|
150
|
+
const enableQueryTimeout = this.driver.options.enableQueryTimeout;
|
|
151
|
+
const maxQueryExecutionTime = this.driver.options.maxQueryExecutionTime;
|
|
152
|
+
const queryPayload = enableQueryTimeout && maxQueryExecutionTime
|
|
153
|
+
? { sql: query, timeout: maxQueryExecutionTime }
|
|
154
|
+
: query;
|
|
150
155
|
const queryStartTime = +new Date();
|
|
151
|
-
databaseConnection.query(
|
|
156
|
+
databaseConnection.query(queryPayload, parameters, async (err, raw) => {
|
|
152
157
|
// log slow queries if maxQueryExecution time is set
|
|
153
158
|
const maxQueryExecutionTime = this.driver.options.maxQueryExecutionTime;
|
|
154
159
|
const queryEndTime = +new Date();
|