feat(products): add reset functionality to delete all products and related data

This commit is contained in:
Nils-Johan Gynther
2026-04-17 21:22:54 +02:00
parent befa15609a
commit e41ee760b9
5 changed files with 93 additions and 0 deletions
+16
View File
@@ -381,4 +381,20 @@ export class ProductsService {
async findAllTags() {
return this.prisma.tag.findMany({ orderBy: { name: 'asc' } });
}
async resetAll() {
await this.prisma.$transaction([
this.prisma.receiptAlias.deleteMany(),
this.prisma.inventoryConsumption.deleteMany(),
this.prisma.inventoryItem.deleteMany(),
this.prisma.pantryItem.deleteMany(),
this.prisma.nutrition.deleteMany(),
this.prisma.productTag.deleteMany(),
this.prisma.tag.deleteMany(),
this.prisma.userProduct.deleteMany(),
this.prisma.recipeIngredient.deleteMany(),
this.prisma.product.deleteMany(),
]);
return { ok: true };
}
}