|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import {
|
|
|
|
|
DeepPartial,
|
|
|
|
|
DeleteResult,
|
|
|
|
|
EntityManager,
|
|
|
|
|
FindManyOptions,
|
|
|
|
|
FindOneOptions,
|
|
|
|
|
FindOptionsWhere,
|
|
|
|
|
@ -29,9 +30,13 @@ export class WorkspaceRepository<
|
|
|
|
|
/**
|
|
|
|
|
* FIND METHODS
|
|
|
|
|
*/
|
|
|
|
|
override async find(options?: FindManyOptions<Entity>): Promise<Entity[]> {
|
|
|
|
|
override async find(
|
|
|
|
|
options?: FindManyOptions<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<Entity[]> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions(options);
|
|
|
|
|
const result = await super.find(computedOptions);
|
|
|
|
|
const result = await manager.find(this.target, computedOptions);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -39,9 +44,11 @@ export class WorkspaceRepository<
|
|
|
|
|
|
|
|
|
|
override async findBy(
|
|
|
|
|
where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<Entity[]> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
const result = await super.findBy(computedOptions.where);
|
|
|
|
|
const result = await manager.findBy(this.target, computedOptions.where);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -49,9 +56,11 @@ export class WorkspaceRepository<
|
|
|
|
|
|
|
|
|
|
override async findAndCount(
|
|
|
|
|
options?: FindManyOptions<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<[Entity[], number]> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions(options);
|
|
|
|
|
const result = await super.findAndCount(computedOptions);
|
|
|
|
|
const result = await manager.findAndCount(this.target, computedOptions);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -59,9 +68,14 @@ export class WorkspaceRepository<
|
|
|
|
|
|
|
|
|
|
override async findAndCountBy(
|
|
|
|
|
where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<[Entity[], number]> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
const result = await super.findAndCountBy(computedOptions.where);
|
|
|
|
|
const result = await manager.findAndCountBy(
|
|
|
|
|
this.target,
|
|
|
|
|
computedOptions.where,
|
|
|
|
|
);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -69,9 +83,11 @@ export class WorkspaceRepository<
|
|
|
|
|
|
|
|
|
|
override async findOne(
|
|
|
|
|
options: FindOneOptions<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<Entity | null> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions(options);
|
|
|
|
|
const result = await super.findOne(computedOptions);
|
|
|
|
|
const result = await manager.findOne(this.target, computedOptions);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -79,9 +95,11 @@ export class WorkspaceRepository<
|
|
|
|
|
|
|
|
|
|
override async findOneBy(
|
|
|
|
|
where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<Entity | null> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
const result = await super.findOneBy(computedOptions.where);
|
|
|
|
|
const result = await manager.findOneBy(this.target, computedOptions.where);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -89,9 +107,11 @@ export class WorkspaceRepository<
|
|
|
|
|
|
|
|
|
|
override async findOneOrFail(
|
|
|
|
|
options: FindOneOptions<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<Entity> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions(options);
|
|
|
|
|
const result = await super.findOneOrFail(computedOptions);
|
|
|
|
|
const result = await manager.findOneOrFail(this.target, computedOptions);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -99,9 +119,14 @@ export class WorkspaceRepository<
|
|
|
|
|
|
|
|
|
|
override async findOneByOrFail(
|
|
|
|
|
where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<Entity> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
const result = await super.findOneByOrFail(computedOptions.where);
|
|
|
|
|
const result = await manager.findOneByOrFail(
|
|
|
|
|
this.target,
|
|
|
|
|
computedOptions.where,
|
|
|
|
|
);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -113,29 +138,40 @@ export class WorkspaceRepository<
|
|
|
|
|
override save<T extends DeepPartial<Entity>>(
|
|
|
|
|
entities: T[],
|
|
|
|
|
options: SaveOptions & { reload: false },
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T[]>;
|
|
|
|
|
|
|
|
|
|
override save<T extends DeepPartial<Entity>>(
|
|
|
|
|
entities: T[],
|
|
|
|
|
options?: SaveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<(T & Entity)[]>;
|
|
|
|
|
|
|
|
|
|
override save<T extends DeepPartial<Entity>>(
|
|
|
|
|
entity: T,
|
|
|
|
|
options: SaveOptions & { reload: false },
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T>;
|
|
|
|
|
|
|
|
|
|
override save<T extends DeepPartial<Entity>>(
|
|
|
|
|
entity: T,
|
|
|
|
|
options?: SaveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T & Entity>;
|
|
|
|
|
|
|
|
|
|
override async save<T extends DeepPartial<Entity>>(
|
|
|
|
|
entityOrEntities: T | T[],
|
|
|
|
|
options?: SaveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T | T[]> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const formattedEntityOrEntities = this.formatData(entityOrEntities);
|
|
|
|
|
const result = await super.save(formattedEntityOrEntities as any, options);
|
|
|
|
|
const result = await manager.save(
|
|
|
|
|
this.target,
|
|
|
|
|
formattedEntityOrEntities as any,
|
|
|
|
|
options,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -147,15 +183,27 @@ export class WorkspaceRepository<
|
|
|
|
|
override remove(
|
|
|
|
|
entities: Entity[],
|
|
|
|
|
options?: RemoveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<Entity[]>;
|
|
|
|
|
|
|
|
|
|
override remove(entity: Entity, options?: RemoveOptions): Promise<Entity>;
|
|
|
|
|
override remove(
|
|
|
|
|
entity: Entity,
|
|
|
|
|
options?: RemoveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<Entity>;
|
|
|
|
|
|
|
|
|
|
override async remove(
|
|
|
|
|
entityOrEntities: Entity | Entity[],
|
|
|
|
|
options?: RemoveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<Entity | Entity[]> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const formattedEntityOrEntities = this.formatData(entityOrEntities);
|
|
|
|
|
const result = await super.remove(formattedEntityOrEntities as any);
|
|
|
|
|
const result = await manager.remove(
|
|
|
|
|
this.target,
|
|
|
|
|
formattedEntityOrEntities,
|
|
|
|
|
options,
|
|
|
|
|
);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -172,40 +220,50 @@ export class WorkspaceRepository<
|
|
|
|
|
| ObjectId
|
|
|
|
|
| ObjectId[]
|
|
|
|
|
| FindOptionsWhere<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<DeleteResult> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
|
|
|
|
|
if (typeof criteria === 'object' && 'where' in criteria) {
|
|
|
|
|
criteria = this.transformOptions(criteria);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.delete(criteria);
|
|
|
|
|
return manager.delete(this.target, criteria);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override softRemove<T extends DeepPartial<Entity>>(
|
|
|
|
|
entities: T[],
|
|
|
|
|
options: SaveOptions & { reload: false },
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T[]>;
|
|
|
|
|
|
|
|
|
|
override softRemove<T extends DeepPartial<Entity>>(
|
|
|
|
|
entities: T[],
|
|
|
|
|
options?: SaveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<(T & Entity)[]>;
|
|
|
|
|
|
|
|
|
|
override softRemove<T extends DeepPartial<Entity>>(
|
|
|
|
|
entity: T,
|
|
|
|
|
options: SaveOptions & { reload: false },
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T>;
|
|
|
|
|
|
|
|
|
|
override softRemove<T extends DeepPartial<Entity>>(
|
|
|
|
|
entity: T,
|
|
|
|
|
options?: SaveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T & Entity>;
|
|
|
|
|
|
|
|
|
|
override async softRemove<T extends DeepPartial<Entity>>(
|
|
|
|
|
entityOrEntities: T | T[],
|
|
|
|
|
options?: SaveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T | T[]> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const formattedEntityOrEntities = this.formatData(entityOrEntities);
|
|
|
|
|
const result = await super.softRemove(
|
|
|
|
|
const result = await manager.softRemove(
|
|
|
|
|
this.target,
|
|
|
|
|
formattedEntityOrEntities as any,
|
|
|
|
|
options,
|
|
|
|
|
);
|
|
|
|
|
@ -225,12 +283,15 @@ export class WorkspaceRepository<
|
|
|
|
|
| ObjectId
|
|
|
|
|
| ObjectId[]
|
|
|
|
|
| FindOptionsWhere<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<UpdateResult> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
|
|
|
|
|
if (typeof criteria === 'object' && 'where' in criteria) {
|
|
|
|
|
criteria = this.transformOptions(criteria);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.softDelete(criteria);
|
|
|
|
|
return manager.softDelete(this.target, criteria);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -239,29 +300,36 @@ export class WorkspaceRepository<
|
|
|
|
|
override recover<T extends DeepPartial<Entity>>(
|
|
|
|
|
entities: T[],
|
|
|
|
|
options: SaveOptions & { reload: false },
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T[]>;
|
|
|
|
|
|
|
|
|
|
override recover<T extends DeepPartial<Entity>>(
|
|
|
|
|
entities: T[],
|
|
|
|
|
options?: SaveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<(T & Entity)[]>;
|
|
|
|
|
|
|
|
|
|
override recover<T extends DeepPartial<Entity>>(
|
|
|
|
|
entity: T,
|
|
|
|
|
options: SaveOptions & { reload: false },
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T>;
|
|
|
|
|
|
|
|
|
|
override recover<T extends DeepPartial<Entity>>(
|
|
|
|
|
entity: T,
|
|
|
|
|
options?: SaveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T & Entity>;
|
|
|
|
|
|
|
|
|
|
override async recover<T extends DeepPartial<Entity>>(
|
|
|
|
|
entityOrEntities: T | T[],
|
|
|
|
|
options?: SaveOptions,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<T | T[]> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const formattedEntityOrEntities = this.formatData(entityOrEntities);
|
|
|
|
|
const result = await super.recover(
|
|
|
|
|
const result = await manager.recover(
|
|
|
|
|
this.target,
|
|
|
|
|
formattedEntityOrEntities as any,
|
|
|
|
|
options,
|
|
|
|
|
);
|
|
|
|
|
@ -281,12 +349,15 @@ export class WorkspaceRepository<
|
|
|
|
|
| ObjectId
|
|
|
|
|
| ObjectId[]
|
|
|
|
|
| FindOptionsWhere<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<UpdateResult> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
|
|
|
|
|
if (typeof criteria === 'object' && 'where' in criteria) {
|
|
|
|
|
criteria = this.transformOptions(criteria);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.restore(criteria);
|
|
|
|
|
return manager.restore(this.target, criteria);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -294,9 +365,11 @@ export class WorkspaceRepository<
|
|
|
|
|
*/
|
|
|
|
|
override async insert(
|
|
|
|
|
entity: QueryDeepPartialEntity<Entity> | QueryDeepPartialEntity<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<InsertResult> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const formatedEntity = this.formatData(entity);
|
|
|
|
|
const result = await super.insert(formatedEntity);
|
|
|
|
|
const result = await manager.insert(this.target, formatedEntity);
|
|
|
|
|
const formattedResult = this.formatResult(result);
|
|
|
|
|
|
|
|
|
|
return formattedResult;
|
|
|
|
|
@ -317,12 +390,15 @@ export class WorkspaceRepository<
|
|
|
|
|
| ObjectId[]
|
|
|
|
|
| FindOptionsWhere<Entity>,
|
|
|
|
|
partialEntity: QueryDeepPartialEntity<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<UpdateResult> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
|
|
|
|
|
if (typeof criteria === 'object' && 'where' in criteria) {
|
|
|
|
|
criteria = this.transformOptions(criteria);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.update(criteria, partialEntity);
|
|
|
|
|
return manager.update(this.target, criteria, partialEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override upsert(
|
|
|
|
|
@ -330,50 +406,63 @@ export class WorkspaceRepository<
|
|
|
|
|
| QueryDeepPartialEntity<Entity>
|
|
|
|
|
| QueryDeepPartialEntity<Entity>[],
|
|
|
|
|
conflictPathsOrOptions: string[] | UpsertOptions<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<InsertResult> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
|
|
|
|
|
const formattedEntityOrEntities = this.formatData(entityOrEntities);
|
|
|
|
|
|
|
|
|
|
return this.upsert(formattedEntityOrEntities, conflictPathsOrOptions);
|
|
|
|
|
return manager.upsert(
|
|
|
|
|
this.target,
|
|
|
|
|
formattedEntityOrEntities,
|
|
|
|
|
conflictPathsOrOptions,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* EXIST METHODS
|
|
|
|
|
*/
|
|
|
|
|
override exist(options?: FindManyOptions<Entity>): Promise<boolean> {
|
|
|
|
|
override exists(
|
|
|
|
|
options?: FindManyOptions<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<boolean> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions(options);
|
|
|
|
|
|
|
|
|
|
return super.exist(computedOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override exists(options?: FindManyOptions<Entity>): Promise<boolean> {
|
|
|
|
|
const computedOptions = this.transformOptions(options);
|
|
|
|
|
|
|
|
|
|
return super.exists(computedOptions);
|
|
|
|
|
return manager.exists(this.target, computedOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override existsBy(
|
|
|
|
|
where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<boolean> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
|
|
|
|
|
return super.existsBy(computedOptions.where);
|
|
|
|
|
return manager.existsBy(this.target, computedOptions.where);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* COUNT METHODS
|
|
|
|
|
*/
|
|
|
|
|
override count(options?: FindManyOptions<Entity>): Promise<number> {
|
|
|
|
|
override count(
|
|
|
|
|
options?: FindManyOptions<Entity>,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<number> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions(options);
|
|
|
|
|
|
|
|
|
|
return super.count(computedOptions);
|
|
|
|
|
return manager.count(this.target, computedOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override countBy(
|
|
|
|
|
where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<number> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
|
|
|
|
|
return super.countBy(computedOptions.where);
|
|
|
|
|
return manager.countBy(this.target, computedOptions.where);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -382,57 +471,79 @@ export class WorkspaceRepository<
|
|
|
|
|
override sum(
|
|
|
|
|
columnName: PickKeysByType<Entity, number>,
|
|
|
|
|
where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<number | null> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
|
|
|
|
|
return super.sum(columnName, computedOptions.where);
|
|
|
|
|
return manager.sum(this.target, columnName, computedOptions.where);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override average(
|
|
|
|
|
columnName: PickKeysByType<Entity, number>,
|
|
|
|
|
where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<number | null> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
|
|
|
|
|
return super.average(columnName, computedOptions.where);
|
|
|
|
|
return manager.average(this.target, columnName, computedOptions.where);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override minimum(
|
|
|
|
|
columnName: PickKeysByType<Entity, number>,
|
|
|
|
|
where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<number | null> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
|
|
|
|
|
return super.minimum(columnName, computedOptions.where);
|
|
|
|
|
return manager.minimum(this.target, columnName, computedOptions.where);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override maximum(
|
|
|
|
|
columnName: PickKeysByType<Entity, number>,
|
|
|
|
|
where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<number | null> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedOptions = this.transformOptions({ where });
|
|
|
|
|
|
|
|
|
|
return super.maximum(columnName, computedOptions.where);
|
|
|
|
|
return manager.maximum(this.target, columnName, computedOptions.where);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override increment(
|
|
|
|
|
conditions: FindOptionsWhere<Entity>,
|
|
|
|
|
propertyPath: string,
|
|
|
|
|
value: number | string,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<UpdateResult> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedConditions = this.transformOptions({ where: conditions });
|
|
|
|
|
|
|
|
|
|
return this.increment(computedConditions.where, propertyPath, value);
|
|
|
|
|
return manager.increment(
|
|
|
|
|
this.target,
|
|
|
|
|
computedConditions.where,
|
|
|
|
|
propertyPath,
|
|
|
|
|
value,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override decrement(
|
|
|
|
|
conditions: FindOptionsWhere<Entity>,
|
|
|
|
|
propertyPath: string,
|
|
|
|
|
value: number | string,
|
|
|
|
|
entityManager?: EntityManager,
|
|
|
|
|
): Promise<UpdateResult> {
|
|
|
|
|
const manager = entityManager || this.manager;
|
|
|
|
|
const computedConditions = this.transformOptions({ where: conditions });
|
|
|
|
|
|
|
|
|
|
return this.decrement(computedConditions.where, propertyPath, value);
|
|
|
|
|
return manager.decrement(
|
|
|
|
|
this.target,
|
|
|
|
|
computedConditions.where,
|
|
|
|
|
propertyPath,
|
|
|
|
|
value,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|