feat: Improve bulk category update functionality with validation and clearer logic
Test Suite / test (24.15.0) (push) Has been cancelled

This commit is contained in:
Nils-Johan Gynther
2026-05-11 10:22:17 +02:00
parent afbc5b91b2
commit 06056c6182
2 changed files with 20 additions and 8 deletions
+6 -3
View File
@@ -389,12 +389,15 @@ export class ProductsService {
async bulkUpdate(ids: number[], data: { categoryId?: number | null }) {
const updateData: Record<string, any> = {};
if ('categoryId' in data) {
if (data.categoryId !== undefined) {
updateData.categoryId = data.categoryId;
}
if (Object.keys(updateData).length === 0) return { updated: 0 };
await this.prisma.product.updateMany({ where: { id: { in: ids } }, data: updateData });
return { updated: ids.length };
const result = await this.prisma.product.updateMany({
where: { id: { in: ids } },
data: updateData,
});
return { updated: result.count };
}
async findUncategorized(): Promise<{ id: number; name: string; canonicalName: string | null }[]> {