|
@@ -1,10 +1,11 @@
|
|
|
-import { Type } from 'shared/shared-types';
|
|
|
|
|
|
|
+import { ID, Type } from 'shared/shared-types';
|
|
|
import { Connection, FindManyOptions, SelectQueryBuilder } from 'typeorm';
|
|
import { Connection, FindManyOptions, SelectQueryBuilder } from 'typeorm';
|
|
|
import { FindOptionsUtils } from 'typeorm/find-options/FindOptionsUtils';
|
|
import { FindOptionsUtils } from 'typeorm/find-options/FindOptionsUtils';
|
|
|
|
|
|
|
|
import { ListQueryOptions } from '../../common/types/common-types';
|
|
import { ListQueryOptions } from '../../common/types/common-types';
|
|
|
import { VendureEntity } from '../../entity/base/base.entity';
|
|
import { VendureEntity } from '../../entity/base/base.entity';
|
|
|
|
|
|
|
|
|
|
+import { parseChannelParam } from './parse-channel-param';
|
|
|
import { parseFilterParams } from './parse-filter-params';
|
|
import { parseFilterParams } from './parse-filter-params';
|
|
|
import { parseSortParams } from './parse-sort-params';
|
|
import { parseSortParams } from './parse-sort-params';
|
|
|
|
|
|
|
@@ -16,6 +17,7 @@ export function buildListQuery<T extends VendureEntity>(
|
|
|
entity: Type<T>,
|
|
entity: Type<T>,
|
|
|
options: ListQueryOptions<T> = {},
|
|
options: ListQueryOptions<T> = {},
|
|
|
relations?: string[],
|
|
relations?: string[],
|
|
|
|
|
+ channelId?: ID,
|
|
|
): SelectQueryBuilder<T> {
|
|
): SelectQueryBuilder<T> {
|
|
|
const skip = options.skip;
|
|
const skip = options.skip;
|
|
|
let take = options.take;
|
|
let take = options.take;
|
|
@@ -42,5 +44,12 @@ export function buildListQuery<T extends VendureEntity>(
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ if (channelId) {
|
|
|
|
|
+ const channelFilter = parseChannelParam(connection, entity, channelId);
|
|
|
|
|
+ if (channelFilter) {
|
|
|
|
|
+ qb.andWhere(channelFilter.clause, channelFilter.parameters);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return qb.orderBy(sort);
|
|
return qb.orderBy(sort);
|
|
|
}
|
|
}
|