mirror of
https://github.com/hexastack/hexabot
synced 2025-04-25 08:50:43 +00:00
fix: use overloading to marke deprecated methods signatures
This commit is contained in:
parent
d3b5070407
commit
d912042f88
@ -275,12 +275,26 @@ export abstract class BaseRepository<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
async find(
|
||||||
|
filter: TFilterQuery<T>,
|
||||||
|
pageQuery?: QuerySortDto<T>,
|
||||||
|
projection?: ProjectionType<T>,
|
||||||
|
): Promise<T[]>;
|
||||||
|
|
||||||
async find(
|
async find(
|
||||||
filter: TFilterQuery<T>,
|
filter: TFilterQuery<T>,
|
||||||
// TODO: QuerySortDto<T> type need to be removed
|
|
||||||
pageQuery?: QuerySortDto<T> | PageQueryDto<T>,
|
pageQuery?: QuerySortDto<T> | PageQueryDto<T>,
|
||||||
projection?: ProjectionType<T>,
|
projection?: ProjectionType<T>,
|
||||||
) {
|
): Promise<T[]>;
|
||||||
|
|
||||||
|
async find(
|
||||||
|
filter: TFilterQuery<T>,
|
||||||
|
pageQuery?: QuerySortDto<T> | PageQueryDto<T>,
|
||||||
|
projection?: ProjectionType<T>,
|
||||||
|
): Promise<T[]> {
|
||||||
const query = this.findQuery(filter, pageQuery, projection);
|
const query = this.findQuery(filter, pageQuery, projection);
|
||||||
return await this.execute(query, this.cls);
|
return await this.execute(query, this.cls);
|
||||||
}
|
}
|
||||||
@ -291,12 +305,26 @@ export abstract class BaseRepository<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
async findAndPopulate(
|
||||||
|
filters: TFilterQuery<T>,
|
||||||
|
pageQuery?: QuerySortDto<T>,
|
||||||
|
projection?: ProjectionType<T>,
|
||||||
|
): Promise<TFull[]>;
|
||||||
|
|
||||||
|
async findAndPopulate(
|
||||||
|
filters: TFilterQuery<T>,
|
||||||
|
pageQuery?: PageQueryDto<T>,
|
||||||
|
projection?: ProjectionType<T>,
|
||||||
|
): Promise<TFull[]>;
|
||||||
|
|
||||||
async findAndPopulate(
|
async findAndPopulate(
|
||||||
filters: TFilterQuery<T>,
|
filters: TFilterQuery<T>,
|
||||||
// TODO: QuerySortDto<T> need to be removed
|
|
||||||
pageQuery?: QuerySortDto<T> | PageQueryDto<T>,
|
pageQuery?: QuerySortDto<T> | PageQueryDto<T>,
|
||||||
projection?: ProjectionType<T>,
|
projection?: ProjectionType<T>,
|
||||||
) {
|
): Promise<TFull[]> {
|
||||||
this.ensureCanPopulate();
|
this.ensureCanPopulate();
|
||||||
const query = this.findQuery(filters, pageQuery, projection).populate(
|
const query = this.findQuery(filters, pageQuery, projection).populate(
|
||||||
this.populate,
|
this.populate,
|
||||||
|
@ -44,21 +44,59 @@ export abstract class BaseService<
|
|||||||
return await this.repository.findOneAndPopulate(criteria, projection);
|
return await this.repository.findOneAndPopulate(criteria, projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
async find(
|
||||||
|
filter: TFilterQuery<T>,
|
||||||
|
pageQuery?: QuerySortDto<T>,
|
||||||
|
projection?: ProjectionType<T>,
|
||||||
|
): Promise<T[]>;
|
||||||
|
|
||||||
|
async find(
|
||||||
|
filter: TFilterQuery<T>,
|
||||||
|
pageQuery?: PageQueryDto<T>,
|
||||||
|
projection?: ProjectionType<T>,
|
||||||
|
): Promise<T[]>;
|
||||||
|
|
||||||
async find(
|
async find(
|
||||||
filter: TFilterQuery<T>,
|
filter: TFilterQuery<T>,
|
||||||
// TODO: QuerySortDto<T> type need to be removed
|
|
||||||
pageQuery?: QuerySortDto<T> | PageQueryDto<T>,
|
pageQuery?: QuerySortDto<T> | PageQueryDto<T>,
|
||||||
projection?: ProjectionType<T>,
|
projection?: ProjectionType<T>,
|
||||||
): Promise<T[]> {
|
): Promise<T[]> {
|
||||||
|
if (Array.isArray(pageQuery))
|
||||||
|
return await this.repository.find(filter, pageQuery, projection);
|
||||||
|
|
||||||
return await this.repository.find(filter, pageQuery, projection);
|
return await this.repository.find(filter, pageQuery, projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
async findAndPopulate(
|
||||||
|
filters: TFilterQuery<T>,
|
||||||
|
pageQuery?: QuerySortDto<T>,
|
||||||
|
projection?: ProjectionType<T>,
|
||||||
|
): Promise<TFull[]>;
|
||||||
|
|
||||||
|
async findAndPopulate(
|
||||||
|
filters: TFilterQuery<T>,
|
||||||
|
pageQuery?: PageQueryDto<T>,
|
||||||
|
projection?: ProjectionType<T>,
|
||||||
|
): Promise<TFull[]>;
|
||||||
|
|
||||||
async findAndPopulate(
|
async findAndPopulate(
|
||||||
filters: TFilterQuery<T>,
|
filters: TFilterQuery<T>,
|
||||||
// TODO: QuerySortDto<T> type need to be removed
|
|
||||||
pageQuery?: QuerySortDto<T> | PageQueryDto<T>,
|
pageQuery?: QuerySortDto<T> | PageQueryDto<T>,
|
||||||
projection?: ProjectionType<T>,
|
projection?: ProjectionType<T>,
|
||||||
) {
|
): Promise<TFull[]> {
|
||||||
|
if (Array.isArray(pageQuery))
|
||||||
|
return await this.repository.findAndPopulate(
|
||||||
|
filters,
|
||||||
|
pageQuery,
|
||||||
|
projection,
|
||||||
|
);
|
||||||
|
|
||||||
return await this.repository.findAndPopulate(
|
return await this.repository.findAndPopulate(
|
||||||
filters,
|
filters,
|
||||||
pageQuery,
|
pageQuery,
|
||||||
|
Loading…
Reference in New Issue
Block a user