Skip to content

Commit

Permalink
perf(core): Upgrade sql requests for more performant memory usage wit…
Browse files Browse the repository at this point in the history
…h big datasets (#2741)
  • Loading branch information
monrostar authored Mar 18, 2024
1 parent c5d47f2 commit 65888cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export class ProductOptionGroupService {
*/
async deleteGroupAndOptionsFromProduct(ctx: RequestContext, id: ID, productId: ID) {
const optionGroup = await this.connection.getEntityOrThrow(ctx, ProductOptionGroup, id, {
relationLoadStrategy: 'query',
loadEagerRelations: false,
relations: ['options', 'product'],
});
const deletedOptionGroup = new ProductOptionGroup(optionGroup);
Expand Down Expand Up @@ -165,6 +167,8 @@ export class ProductOptionGroupService {
// hard delete

const product = await this.connection.getRepository(ctx, Product).findOne({
relationLoadStrategy: 'query',
loadEagerRelations: false,
where: { id: productId },
relations: ['optionGroups'],
});
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/service/services/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ export class ProductService {

async softDelete(ctx: RequestContext, productId: ID): Promise<DeletionResponse> {
const product = await this.connection.getEntityOrThrow(ctx, Product, productId, {
relationLoadStrategy: 'query',
loadEagerRelations: false,
channelId: ctx.channelId,
relations: ['variants', 'optionGroups'],
});
Expand Down Expand Up @@ -449,6 +451,8 @@ export class ProductService {

private async getProductWithOptionGroups(ctx: RequestContext, productId: ID): Promise<Product> {
const product = await this.connection.getRepository(ctx, Product).findOne({
relationLoadStrategy: 'query',
loadEagerRelations: false,
where: { id: productId, deletedAt: IsNull() },
relations: ['optionGroups', 'variants', 'variants.options'],
});
Expand Down

0 comments on commit 65888cb

Please sign in to comment.