This commit is contained in:
2026-01-07 12:13:45 +03:30
parent 27ebf4a7b6
commit f2284c103d
235 changed files with 180468 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
import type { EntityManager } from '@mikro-orm/core';
import { Food } from '../modules/foods/entities/food.entity';
import { Inventory } from '../modules/inventory/entities/inventory.entity';
export class InventorySeeder {
async run(em: EntityManager): Promise<void> {
const foods = await em.find(Food, {});
for (const food of foods) {
// Check if inventory already exists for this food
const existingInventory = await em.findOne(Inventory, {
food: { id: food.id },
});
if (!existingInventory) {
const inventory = em.create(Inventory, {
food,
totalStock: 50,
availableStock: 50,
});
em.persist(inventory);
}
}
await em.flush();
}
}