Skip to content

Commit 8041c0a

Browse files
committed
[PUSH] FIX: ADD MERCHANT TO DEMO DATA
1 parent f6da950 commit 8041c0a

1 file changed

Lines changed: 25 additions & 24 deletions

File tree

server/utills/insertDemoData.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -239,33 +239,34 @@ const demoCategories = [
239239
];
240240

241241
async function insertDemoData() {
242-
// Gunakan Promise.all untuk menjalankan operasi secara paralel
243-
const promises = [
244-
// Operasi untuk menyisipkan merchant
245-
...demoMerchant.map((merchant) =>
246-
prisma.merchant.create({ data: merchant })
247-
),
248-
// Operasi untuk menyisipkan categories
249-
...demoCategories.map((category) =>
250-
prisma.category.create({ data: category })
251-
),
252-
// Operasi untuk menyisipkan products
253-
...demoProducts.map((product) =>
254-
prisma.product.create({ data: product })
255-
),
256-
];
257242

258-
try {
259-
// Tunggu semua promise selesai
260-
await Promise.all(promises);
243+
for (const merchant of demoMerchant) {
244+
await prisma.merchant.create({
245+
data: merchant,
246+
});
247+
}
248+
console.log("Demo merchant inserted successfully!");
249+
250+
for (const category of demoCategories) {
251+
await prisma.category.create({
252+
data: category,
253+
});
254+
}
255+
console.log("Demo categories inserted successfully!");
261256

262-
console.log("All demo data inserted successfully!");
263-
} catch (error) {
264-
console.error("Error inserting demo data:", error);
257+
for (const product of demoProducts) {
258+
await prisma.product.create({
259+
data: product,
260+
});
265261
}
262+
console.log("Demo products inserted successfully!");
266263
}
267264

268265
insertDemoData()
269-
.finally(async () => {
270-
await prisma.$disconnect(); // Pastikan koneksi Prisma ditutup setelah selesai
271-
});
266+
.catch((error) => {
267+
console.error(error);
268+
process.exit(1);
269+
})
270+
.finally(async () => {
271+
await prisma.$disconnect();
272+
});

0 commit comments

Comments
 (0)