typeorm 0.2.42-dev.bd22dc3 → 0.2.42-dev.cefddd9
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/cache/RedisQueryResultCache.js +40 -35
- package/browser/cache/RedisQueryResultCache.js.map +1 -1
- package/browser/connection/Connection.d.ts +2 -2
- package/browser/connection/Connection.js +1 -1
- package/browser/connection/Connection.js.map +1 -1
- package/browser/decorator/Unique.d.ts +5 -4
- package/browser/decorator/Unique.js +7 -3
- package/browser/decorator/Unique.js.map +1 -1
- package/browser/decorator/options/RelationOptions.d.ts +1 -1
- package/browser/decorator/options/RelationOptions.js.map +1 -1
- package/browser/decorator/options/UniqueOptions.d.ts +10 -0
- package/browser/decorator/options/UniqueOptions.js +3 -0
- package/browser/decorator/options/UniqueOptions.js.map +1 -0
- package/browser/driver/postgres/PostgresQueryRunner.js +10 -3
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/entity-manager/EntityManager.d.ts +2 -2
- package/browser/entity-manager/EntityManager.js +1 -1
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/entity-manager/MongoEntityManager.js +2 -1
- package/browser/entity-manager/MongoEntityManager.js.map +1 -1
- package/browser/entity-schema/EntitySchemaRelationOptions.d.ts +1 -1
- package/browser/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/browser/entity-schema/EntitySchemaTransformer.js +2 -1
- package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/browser/entity-schema/EntitySchemaUniqueOptions.d.ts +5 -0
- package/browser/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
- package/browser/metadata/RelationMetadata.d.ts +1 -1
- package/browser/metadata/RelationMetadata.js.map +1 -1
- package/browser/metadata/UniqueMetadata.d.ts +5 -0
- package/browser/metadata/UniqueMetadata.js +1 -0
- package/browser/metadata/UniqueMetadata.js.map +1 -1
- package/browser/metadata-args/UniqueMetadataArgs.d.ts +5 -0
- package/browser/metadata-args/UniqueMetadataArgs.js.map +1 -1
- package/browser/persistence/subject-builder/OneToManySubjectBuilder.js +3 -0
- package/browser/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/browser/query-builder/DeleteQueryBuilder.d.ts +1 -1
- package/browser/query-builder/DeleteQueryBuilder.js +1 -1
- package/browser/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/browser/query-builder/InsertQueryBuilder.d.ts +1 -1
- package/browser/query-builder/InsertQueryBuilder.js +1 -1
- package/browser/query-builder/InsertQueryBuilder.js.map +1 -1
- package/browser/query-builder/QueryBuilder.d.ts +1 -1
- package/browser/query-builder/QueryBuilder.js.map +1 -1
- package/browser/query-builder/RelationQueryBuilder.d.ts +1 -1
- package/browser/query-builder/RelationQueryBuilder.js +1 -1
- package/browser/query-builder/RelationQueryBuilder.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +1 -1
- package/browser/query-builder/SelectQueryBuilder.js +1 -1
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/query-builder/SoftDeleteQueryBuilder.d.ts +1 -1
- package/browser/query-builder/SoftDeleteQueryBuilder.js +1 -1
- package/browser/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/browser/query-builder/UpdateQueryBuilder.d.ts +1 -1
- package/browser/query-builder/UpdateQueryBuilder.js +8 -5
- package/browser/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/browser/repository/AbstractRepository.d.ts +2 -2
- package/browser/repository/AbstractRepository.js +2 -2
- package/browser/repository/AbstractRepository.js.map +1 -1
- package/browser/repository/BaseEntity.d.ts +1 -1
- package/browser/repository/BaseEntity.js +1 -1
- package/browser/repository/BaseEntity.js.map +1 -1
- package/browser/repository/Repository.d.ts +1 -1
- package/browser/repository/Repository.js +1 -1
- package/browser/repository/Repository.js.map +1 -1
- package/browser/schema-builder/options/TableUniqueOptions.d.ts +5 -0
- package/browser/schema-builder/options/TableUniqueOptions.js.map +1 -1
- package/browser/schema-builder/table/TableUnique.d.ts +5 -0
- package/browser/schema-builder/table/TableUnique.js +5 -2
- package/browser/schema-builder/table/TableUnique.js.map +1 -1
- package/cache/RedisQueryResultCache.js +39 -34
- package/cache/RedisQueryResultCache.js.map +1 -1
- package/commands/QueryCommand.d.ts +1 -1
- package/commands/QueryCommand.js +1 -1
- package/commands/QueryCommand.js.map +1 -1
- package/connection/Connection.d.ts +2 -2
- package/connection/Connection.js +1 -1
- package/connection/Connection.js.map +1 -1
- package/decorator/Unique.d.ts +5 -4
- package/decorator/Unique.js +7 -3
- package/decorator/Unique.js.map +1 -1
- package/decorator/options/RelationOptions.d.ts +1 -1
- package/decorator/options/RelationOptions.js.map +1 -1
- package/decorator/options/UniqueOptions.d.ts +10 -0
- package/decorator/options/UniqueOptions.js +4 -0
- package/decorator/options/UniqueOptions.js.map +1 -0
- package/driver/postgres/PostgresQueryRunner.js +10 -3
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/entity-manager/EntityManager.d.ts +2 -2
- package/entity-manager/EntityManager.js +1 -1
- package/entity-manager/EntityManager.js.map +1 -1
- package/entity-manager/MongoEntityManager.js +2 -1
- package/entity-manager/MongoEntityManager.js.map +1 -1
- package/entity-schema/EntitySchemaRelationOptions.d.ts +1 -1
- package/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/entity-schema/EntitySchemaTransformer.js +2 -1
- package/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/entity-schema/EntitySchemaUniqueOptions.d.ts +5 -0
- package/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
- package/metadata/RelationMetadata.d.ts +1 -1
- package/metadata/RelationMetadata.js.map +1 -1
- package/metadata/UniqueMetadata.d.ts +5 -0
- package/metadata/UniqueMetadata.js +1 -0
- package/metadata/UniqueMetadata.js.map +1 -1
- package/metadata-args/UniqueMetadataArgs.d.ts +5 -0
- package/metadata-args/UniqueMetadataArgs.js.map +1 -1
- package/package.json +1 -1
- package/persistence/subject-builder/OneToManySubjectBuilder.js +3 -0
- package/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/query-builder/DeleteQueryBuilder.d.ts +1 -1
- package/query-builder/DeleteQueryBuilder.js +1 -1
- package/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/query-builder/InsertQueryBuilder.d.ts +1 -1
- package/query-builder/InsertQueryBuilder.js +1 -1
- package/query-builder/InsertQueryBuilder.js.map +1 -1
- package/query-builder/QueryBuilder.d.ts +1 -1
- package/query-builder/QueryBuilder.js.map +1 -1
- package/query-builder/RelationQueryBuilder.d.ts +1 -1
- package/query-builder/RelationQueryBuilder.js +1 -1
- package/query-builder/RelationQueryBuilder.js.map +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +1 -1
- package/query-builder/SelectQueryBuilder.js +1 -1
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/query-builder/SoftDeleteQueryBuilder.d.ts +1 -1
- package/query-builder/SoftDeleteQueryBuilder.js +1 -1
- package/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/query-builder/UpdateQueryBuilder.d.ts +1 -1
- package/query-builder/UpdateQueryBuilder.js +8 -5
- package/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/repository/AbstractRepository.d.ts +2 -2
- package/repository/AbstractRepository.js +2 -2
- package/repository/AbstractRepository.js.map +1 -1
- package/repository/BaseEntity.d.ts +1 -1
- package/repository/BaseEntity.js +1 -1
- package/repository/BaseEntity.js.map +1 -1
- package/repository/Repository.d.ts +1 -1
- package/repository/Repository.js +1 -1
- package/repository/Repository.js.map +1 -1
- package/schema-builder/options/TableUniqueOptions.d.ts +5 -0
- package/schema-builder/options/TableUniqueOptions.js.map +1 -1
- package/schema-builder/table/TableUnique.d.ts +5 -0
- package/schema-builder/table/TableUnique.js +5 -2
- package/schema-builder/table/TableUnique.js.map +1 -1
package/repository/Repository.js
CHANGED
|
@@ -12,7 +12,7 @@ var Repository = /** @class */ (function () {
|
|
|
12
12
|
// Public Methods
|
|
13
13
|
// -------------------------------------------------------------------------
|
|
14
14
|
/**
|
|
15
|
-
* Creates a new query builder that can be used to build a
|
|
15
|
+
* Creates a new query builder that can be used to build a SQL query.
|
|
16
16
|
*/
|
|
17
17
|
Repository.prototype.createQueryBuilder = function (alias, queryRunner) {
|
|
18
18
|
return this.manager.createQueryBuilder(this.metadata.target, alias || this.metadata.targetName, queryRunner || this.queryRunner);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/repository/Repository.ts"],"names":[],"mappings":";;;;AAkBA;;GAEG;AACH;IAAA;IAiaA,CAAC;IA5YG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,uCAAkB,GAAlB,UAAmB,KAAc,EAAE,WAAyB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAS,IAAI,CAAC,QAAQ,CAAC,MAAa,EAAE,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IACpJ,CAAC;IAOD,sBAAI,8BAAM;QALV;;;;WAIG;aACH;YACI,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAChC,CAAC;;;OAAA;IAED;;;OAGG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAmBD;;;OAGG;IACH,2BAAM,GAAN,UAAO,iCAA6E;QAChF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,IAAI,CAAC,QAAQ,CAAC,MAAa,EAAE,iCAAwC,CAAC,C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AAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAED;;OAEG;IACH,8BAAS,GAAT,UAAU,UAAkC,EAAE,YAAoB,EAAE,KAAsB;QACtF,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAEL,iBAAC;AAAD,CAjaA,AAiaC,IAAA;AAjaY,gCAAU","file":"Repository.js","sourcesContent":["import {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {FindManyOptions} from \"../find-options/FindManyOptions\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {FindOneOptions} from \"../find-options/FindOneOptions\";\nimport {DeepPartial} from \"../common/DeepPartial\";\nimport {SaveOptions} from \"./SaveOptions\";\nimport {RemoveOptions} from \"./RemoveOptions\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {DeleteResult} from \"../query-builder/result/DeleteResult\";\nimport {UpdateResult} from \"../query-builder/result/UpdateResult\";\nimport {InsertResult} from \"../query-builder/result/InsertResult\";\nimport {QueryDeepPartialEntity} from \"../query-builder/QueryPartialEntity\";\nimport {ObjectID} from \"../driver/mongodb/typings\";\nimport {FindConditions} from \"../find-options/FindConditions\";\nimport {UpsertOptions} from \"./UpsertOptions\";\n\n/**\n * Repository is supposed to work with your entity objects. Find entities, insert, update, delete, etc.\n */\nexport class Repository<Entity extends ObjectLiteral> {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: EntityManager;\n\n /**\n * Entity metadata of the entity current repository manages.\n */\n readonly metadata: EntityMetadata;\n\n /**\n * Query runner provider used for this repository.\n */\n readonly queryRunner?: QueryRunner;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new query builder that can be used to build a sql query.\n */\n createQueryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {\n return this.manager.createQueryBuilder<Entity>(this.metadata.target as any, alias || this.metadata.targetName, queryRunner || this.queryRunner);\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n get target(): Function|string {\n return this.metadata.target;\n }\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(entity: Entity): boolean {\n return this.manager.hasId(this.metadata.target, entity);\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: Entity): any {\n return this.manager.getId(this.metadata.target, entity);\n }\n\n /**\n * Creates a new entity instance.\n */\n create(): Entity;\n\n /**\n * Creates new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLikeArray: DeepPartial<Entity>[]): Entity[];\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLike: DeepPartial<Entity>): Entity;\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create(plainEntityLikeOrPlainEntityLikes?: DeepPartial<Entity>|DeepPartial<Entity>[]): Entity|Entity[] {\n return this.manager.create<any>(this.metadata.target as any, plainEntityLikeOrPlainEntityLikes as any);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n merge(mergeIntoEntity: Entity, ...entityLikes: DeepPartial<Entity>[]): Entity {\n return this.manager.merge(this.metadata.target as any, mergeIntoEntity, ...entityLikes);\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n *\n * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n preload(entityLike: DeepPartial<Entity>): Promise<Entity|undefined> {\n return this.manager.preload(this.metadata.target as any, entityLike);\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Saves one or many given entities.\n */\n save<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.save<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n remove(entities: Entity[], options?: RemoveOptions): Promise<Entity[]>;\n\n /**\n * Removes a given entity from the database.\n */\n remove(entity: Entity, options?: RemoveOptions): Promise<Entity>;\n\n /**\n * Removes one or many given entities.\n */\n remove(entityOrEntities: Entity|Entity[], options?: RemoveOptions): Promise<Entity|Entity[]> {\n return this.manager.remove(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.softRemove<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Recovers one or many given entities.\n */\n recover<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.recover<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n */\n insert(entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[])): Promise<InsertResult> {\n return this.manager.insert(this.metadata.target as any, entity);\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n */\n update(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult> {\n return this.manager.update(this.metadata.target as any, criteria as any, partialEntity);\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n upsert(\n entityOrEntities: QueryDeepPartialEntity<Entity> | (QueryDeepPartialEntity<Entity>[]),\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>): Promise<InsertResult> {\n return this.manager.upsert(this.metadata.target as any, entityOrEntities, conflictPathsOrOptions);\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n */\n delete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<DeleteResult> {\n return this.manager.delete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Records the delete date of entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n softDelete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.softDelete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Restores entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n restore(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.restore(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Counts entities that match given options.\n */\n count(options?: FindManyOptions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n count(conditions?: FindConditions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n count(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<number> {\n return this.manager.count(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n find(options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n find(conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.find(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(options?: FindManyOptions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(conditions?: FindConditions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<[ Entity[], number ]> {\n return this.manager.findAndCount(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n findByIds(ids: any[], conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target as any, ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity|undefined> {\n return this.manager.findOne(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n query(query: string, parameters?: any[]): Promise<any> {\n return this.manager.query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n clear(): Promise<void> {\n return this.manager.clear(this.metadata.target);\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n increment(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.increment(this.metadata.target, conditions, propertyPath, value);\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n decrement(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.decrement(this.metadata.target, conditions, propertyPath, value);\n }\n\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/repository/Repository.ts"],"names":[],"mappings":";;;;AAkBA;;GAEG;AACH;IAAA;IAiaA,CAAC;IA5YG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,uCAAkB,GAAlB,UAAmB,KAAc,EAAE,WAAyB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAS,IAAI,CAAC,QAAQ,CAAC,MAAa,EAAE,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IACpJ,CAAC;IAOD,sBAAI,8BAAM;QALV;;;;WAIG;aACH;YACI,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAChC,CAAC;;;OAAA;IAED;;;OAGG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAmBD;;;OAGG;IACH,2BAAM,GAAN,UAAO,iCAA6E;QAChF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,IAAI,CAAC,QAAQ,CAAC,MAAa,EAAE,iCAAwC,CAAC,CAAC;IAC3G,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL,UAAM,eAAuB;;QAAE,qBAAqC;aAArC,UAAqC,EAArC,qBAAqC,EAArC,IAAqC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AC;IAED;;OAEG;IACH,8BAAS,GAAT,UAAU,UAAkC,EAAE,YAAoB,EAAE,KAAsB;QACtF,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAEL,iBAAC;AAAD,CAjaA,AAiaC,IAAA;AAjaY,gCAAU","file":"Repository.js","sourcesContent":["import {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {FindManyOptions} from \"../find-options/FindManyOptions\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {FindOneOptions} from \"../find-options/FindOneOptions\";\nimport {DeepPartial} from \"../common/DeepPartial\";\nimport {SaveOptions} from \"./SaveOptions\";\nimport {RemoveOptions} from \"./RemoveOptions\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {DeleteResult} from \"../query-builder/result/DeleteResult\";\nimport {UpdateResult} from \"../query-builder/result/UpdateResult\";\nimport {InsertResult} from \"../query-builder/result/InsertResult\";\nimport {QueryDeepPartialEntity} from \"../query-builder/QueryPartialEntity\";\nimport {ObjectID} from \"../driver/mongodb/typings\";\nimport {FindConditions} from \"../find-options/FindConditions\";\nimport {UpsertOptions} from \"./UpsertOptions\";\n\n/**\n * Repository is supposed to work with your entity objects. Find entities, insert, update, delete, etc.\n */\nexport class Repository<Entity extends ObjectLiteral> {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: EntityManager;\n\n /**\n * Entity metadata of the entity current repository manages.\n */\n readonly metadata: EntityMetadata;\n\n /**\n * Query runner provider used for this repository.\n */\n readonly queryRunner?: QueryRunner;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {\n return this.manager.createQueryBuilder<Entity>(this.metadata.target as any, alias || this.metadata.targetName, queryRunner || this.queryRunner);\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n get target(): Function|string {\n return this.metadata.target;\n }\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(entity: Entity): boolean {\n return this.manager.hasId(this.metadata.target, entity);\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: Entity): any {\n return this.manager.getId(this.metadata.target, entity);\n }\n\n /**\n * Creates a new entity instance.\n */\n create(): Entity;\n\n /**\n * Creates new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLikeArray: DeepPartial<Entity>[]): Entity[];\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLike: DeepPartial<Entity>): Entity;\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create(plainEntityLikeOrPlainEntityLikes?: DeepPartial<Entity>|DeepPartial<Entity>[]): Entity|Entity[] {\n return this.manager.create<any>(this.metadata.target as any, plainEntityLikeOrPlainEntityLikes as any);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n merge(mergeIntoEntity: Entity, ...entityLikes: DeepPartial<Entity>[]): Entity {\n return this.manager.merge(this.metadata.target as any, mergeIntoEntity, ...entityLikes);\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n *\n * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n preload(entityLike: DeepPartial<Entity>): Promise<Entity|undefined> {\n return this.manager.preload(this.metadata.target as any, entityLike);\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Saves one or many given entities.\n */\n save<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.save<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n remove(entities: Entity[], options?: RemoveOptions): Promise<Entity[]>;\n\n /**\n * Removes a given entity from the database.\n */\n remove(entity: Entity, options?: RemoveOptions): Promise<Entity>;\n\n /**\n * Removes one or many given entities.\n */\n remove(entityOrEntities: Entity|Entity[], options?: RemoveOptions): Promise<Entity|Entity[]> {\n return this.manager.remove(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.softRemove<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Recovers one or many given entities.\n */\n recover<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.recover<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n */\n insert(entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[])): Promise<InsertResult> {\n return this.manager.insert(this.metadata.target as any, entity);\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n */\n update(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult> {\n return this.manager.update(this.metadata.target as any, criteria as any, partialEntity);\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n upsert(\n entityOrEntities: QueryDeepPartialEntity<Entity> | (QueryDeepPartialEntity<Entity>[]),\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>): Promise<InsertResult> {\n return this.manager.upsert(this.metadata.target as any, entityOrEntities, conflictPathsOrOptions);\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n */\n delete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<DeleteResult> {\n return this.manager.delete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Records the delete date of entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n softDelete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.softDelete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Restores entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n restore(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.restore(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Counts entities that match given options.\n */\n count(options?: FindManyOptions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n count(conditions?: FindConditions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n count(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<number> {\n return this.manager.count(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n find(options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n find(conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.find(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(options?: FindManyOptions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(conditions?: FindConditions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<[ Entity[], number ]> {\n return this.manager.findAndCount(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n findByIds(ids: any[], conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target as any, ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity|undefined> {\n return this.manager.findOne(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n query(query: string, parameters?: any[]): Promise<any> {\n return this.manager.query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n clear(): Promise<void> {\n return this.manager.clear(this.metadata.target);\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n increment(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.increment(this.metadata.target, conditions, propertyPath, value);\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n decrement(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.decrement(this.metadata.target, conditions, propertyPath, value);\n }\n\n}\n"],"sourceRoot":".."}
|
|
@@ -10,4 +10,9 @@ export interface TableUniqueOptions {
|
|
|
10
10
|
* Columns that contains this constraint.
|
|
11
11
|
*/
|
|
12
12
|
columnNames: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Set this foreign key constraint as "DEFERRABLE" e.g. check constraints at start
|
|
15
|
+
* or at the end of a transaction
|
|
16
|
+
*/
|
|
17
|
+
deferrable?: string;
|
|
13
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema-builder/options/TableUniqueOptions.ts"],"names":[],"mappings":"","file":"TableUniqueOptions.js","sourcesContent":["/**\n * Database's table unique constraint options.\n */\nexport interface TableUniqueOptions {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[];\n\n}"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/schema-builder/options/TableUniqueOptions.ts"],"names":[],"mappings":"","file":"TableUniqueOptions.js","sourcesContent":["/**\n * Database's table unique constraint options.\n */\nexport interface TableUniqueOptions {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[];\n\n /**\n * Set this foreign key constraint as \"DEFERRABLE\" e.g. check constraints at start\n * or at the end of a transaction\n */\n deferrable?: string;\n\n}"],"sourceRoot":"../.."}
|
|
@@ -12,6 +12,11 @@ export declare class TableUnique {
|
|
|
12
12
|
* Columns that contains this constraint.
|
|
13
13
|
*/
|
|
14
14
|
columnNames: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Set this foreign key constraint as "DEFERRABLE" e.g. check constraints at start
|
|
17
|
+
* or at the end of a transaction
|
|
18
|
+
*/
|
|
19
|
+
deferrable?: string;
|
|
15
20
|
constructor(options: TableUniqueOptions);
|
|
16
21
|
/**
|
|
17
22
|
* Creates a new copy of this constraint with exactly same properties.
|
|
@@ -16,6 +16,7 @@ var TableUnique = /** @class */ (function () {
|
|
|
16
16
|
this.columnNames = [];
|
|
17
17
|
this.name = options.name;
|
|
18
18
|
this.columnNames = options.columnNames;
|
|
19
|
+
this.deferrable = options.deferrable;
|
|
19
20
|
}
|
|
20
21
|
// -------------------------------------------------------------------------
|
|
21
22
|
// Public Methods
|
|
@@ -26,7 +27,8 @@ var TableUnique = /** @class */ (function () {
|
|
|
26
27
|
TableUnique.prototype.clone = function () {
|
|
27
28
|
return new TableUnique({
|
|
28
29
|
name: this.name,
|
|
29
|
-
columnNames: (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(this.columnNames), false)
|
|
30
|
+
columnNames: (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(this.columnNames), false),
|
|
31
|
+
deferrable: this.deferrable,
|
|
30
32
|
});
|
|
31
33
|
};
|
|
32
34
|
// -------------------------------------------------------------------------
|
|
@@ -38,7 +40,8 @@ var TableUnique = /** @class */ (function () {
|
|
|
38
40
|
TableUnique.create = function (uniqueMetadata) {
|
|
39
41
|
return new TableUnique({
|
|
40
42
|
name: uniqueMetadata.name,
|
|
41
|
-
columnNames: uniqueMetadata.columns.map(function (column) { return column.databaseName; })
|
|
43
|
+
columnNames: uniqueMetadata.columns.map(function (column) { return column.databaseName; }),
|
|
44
|
+
deferrable: uniqueMetadata.deferrable,
|
|
42
45
|
});
|
|
43
46
|
};
|
|
44
47
|
return TableUnique;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema-builder/table/TableUnique.ts"],"names":[],"mappings":";;;;AAGA;;GAEG;AACH;
|
|
1
|
+
{"version":3,"sources":["../../src/schema-builder/table/TableUnique.ts"],"names":[],"mappings":";;;;AAGA;;GAEG;AACH;IAsBI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAY,OAA2B;QAfvC;;WAEG;QACH,gBAAW,GAAa,EAAE,CAAC;QAavB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACzC,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,2BAAK,GAAL;QACI,OAAO,IAAI,WAAW,CAAqB;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,qDAAM,IAAI,CAAC,WAAW,SAAC;YAClC,UAAU,EAAE,IAAI,CAAC,UAAU;SAC9B,CAAC,CAAC;IACP,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACI,kBAAM,GAAb,UAAc,cAA8B;QACxC,OAAO,IAAI,WAAW,CAAqB;YACvC,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,WAAW,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,YAAY,EAAnB,CAAmB,CAAC;YACtE,UAAU,EAAE,cAAc,CAAC,UAAU;SACxC,CAAC,CAAC;IACP,CAAC;IAEL,kBAAC;AAAD,CA9DA,AA8DC,IAAA;AA9DY,kCAAW","file":"TableUnique.js","sourcesContent":["import {TableUniqueOptions} from \"../options/TableUniqueOptions\";\nimport {UniqueMetadata} from \"../../metadata/UniqueMetadata\";\n\n/**\n * Database's table unique constraint stored in this class.\n */\nexport class TableUnique {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[] = [];\n\n /**\n * Set this foreign key constraint as \"DEFERRABLE\" e.g. check constraints at start\n * or at the end of a transaction\n */\n deferrable?: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options: TableUniqueOptions) {\n this.name = options.name;\n this.columnNames = options.columnNames;\n this.deferrable = options.deferrable;\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new copy of this constraint with exactly same properties.\n */\n clone(): TableUnique {\n return new TableUnique(<TableUniqueOptions>{\n name: this.name,\n columnNames: [...this.columnNames],\n deferrable: this.deferrable,\n });\n }\n\n // -------------------------------------------------------------------------\n // Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates unique from the unique metadata object.\n */\n static create(uniqueMetadata: UniqueMetadata): TableUnique {\n return new TableUnique(<TableUniqueOptions>{\n name: uniqueMetadata.name,\n columnNames: uniqueMetadata.columns.map(column => column.databaseName),\n deferrable: uniqueMetadata.deferrable,\n });\n }\n\n}"],"sourceRoot":"../.."}
|