refactor(products): remove subcategory from Product model and related queries

This commit is contained in:
Nils-Johan Gynther
2026-05-03 15:54:23 +02:00
parent 5864a6f111
commit dbd8c6d849
4 changed files with 6 additions and 10 deletions
-1
View File
@@ -33,7 +33,6 @@ model Product {
name String
normalizedName String @unique
category String?
subcategory String?
brand String?
canonicalName String?
isActive Boolean @default(true)
+1 -2
View File
@@ -42,9 +42,8 @@ export class ProductsController {
@Get()
findAll(
@Query('tag') tag?: string,
@Query('subcategory') subcategory?: string,
) {
return this.productsService.findAll({ tag, subcategory });
return this.productsService.findAll({ tag });
}
@Public()
+1 -7
View File
@@ -15,12 +15,11 @@ export class ProductsService {
private readonly categoriesService: CategoriesService,
) {}
async findAll(filters?: { tag?: string; subcategory?: string }) {
async findAll(filters?: { tag?: string }) {
return this.prisma.product.findMany({
where: {
isActive: true,
isPrivate: false,
...(filters?.subcategory ? { subcategory: filters.subcategory } : {}),
...(filters?.tag
? { tags: { some: { tag: { name: filters.tag } } } }
: {}),
@@ -165,7 +164,6 @@ export class ProductsService {
normalizedName?: string;
canonicalName?: string;
category?: string | null;
subcategory?: string | null;
brand?: string | null;
categoryId?: number | null;
} = {};
@@ -195,10 +193,6 @@ export class ProductsService {
updateData.category = data.category.trim() || null;
}
if (typeof data.subcategory === 'string') {
updateData.subcategory = data.subcategory.trim() || null;
}
if (typeof data.brand === 'string') {
updateData.brand = data.brand.trim() || null;
}