feat: Improve bulk category update functionality with validation and clearer logic
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -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 }[]> {
|
||||
|
||||
Reference in New Issue
Block a user