import type { EntityManager } from '@mikro-orm/core'; import { Restaurant } from '../modules/restaurants/entities/restaurant.entity'; import { restaurantsData } from './data/restaurants.data'; export class RestaurantsSeeder { async run(em: EntityManager): Promise> { const restaurantsMap = new Map(); for (const restaurantData of restaurantsData) { let restaurant = await em.findOne(Restaurant, { slug: restaurantData.slug }); if (!restaurant) { restaurant = em.create(Restaurant, { ...restaurantData, subscriptionStartDate: new Date('2026-01-01'), subscriptionEndDate: new Date('2026-01-07'), isActive: true, }); em.persist(restaurant); } restaurantsMap.set(restaurantData.slug, restaurant); } await em.flush(); return restaurantsMap; } }