category
This commit is contained in:
@@ -235,23 +235,28 @@ export class DatabaseSeeder extends Seeder {
|
||||
|
||||
// 6. Create Categories (Farsi)
|
||||
const categories = [
|
||||
{ title: 'غذای اصلی', restId: zhivan?.id },
|
||||
{ title: 'پیش غذا', restId: zhivan?.id },
|
||||
{ title: 'دسر', restId: zhivan?.id },
|
||||
{ title: 'نوشیدنی', restId: zhivan?.id },
|
||||
{ title: 'غذای اصلی', restId: boote?.id },
|
||||
{ title: 'پیش غذا', restId: boote?.id },
|
||||
{ title: 'دسر', restId: boote?.id },
|
||||
{ title: 'نوشیدنی', restId: boote?.id },
|
||||
{ title: 'غذای اصلی', restaurant: zhivan },
|
||||
{ title: 'پیش غذا', restaurant: zhivan },
|
||||
{ title: 'دسر', restaurant: zhivan },
|
||||
{ title: 'نوشیدنی', restaurant: zhivan },
|
||||
{ title: 'غذای اصلی', restaurant: boote },
|
||||
{ title: 'پیش غذا', restaurant: boote },
|
||||
{ title: 'دسر', restaurant: boote },
|
||||
{ title: 'نوشیدنی', restaurant: boote },
|
||||
];
|
||||
|
||||
const createdCategories: Category[] = [];
|
||||
for (const catData of categories) {
|
||||
const existing = await em.findOne(Category, { title: catData.title, restId: catData.restId });
|
||||
if (!catData.restaurant) continue;
|
||||
|
||||
const existing = await em.findOne(Category, {
|
||||
title: catData.title,
|
||||
restaurant: catData.restaurant,
|
||||
});
|
||||
if (!existing) {
|
||||
const category = em.create(Category, {
|
||||
title: catData.title,
|
||||
restId: catData.restId,
|
||||
restaurant: catData.restaurant,
|
||||
isActive: true,
|
||||
});
|
||||
em.persist(category);
|
||||
|
||||
Reference in New Issue
Block a user