VendorSeeder.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const prisma = require('../../src/prisma/PrismaClient.js');
  2. async function seedVendors() {
  3. try {
  4. // cari user role admin
  5. const adminUser = await prisma.user.findFirst({
  6. where: {
  7. username: 'admin1',
  8. },
  9. });
  10. if (!adminUser) {
  11. throw new Error('User with role admin not exists');
  12. }
  13. // Data vendor yang akan dimasukkan
  14. const vendors = [
  15. {
  16. name: 'MediSoft SIMRS',
  17. name_pt: 'PT Medisoft Technology',
  18. strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
  19. weaknesses: 'Harga relatif tinggi',
  20. website: 'https://medisoft.co.id',
  21. },
  22. {
  23. name: 'SimRS Platinum',
  24. name_pt: 'PT Platinum Healthtech',
  25. strengths: 'Integrasi BPJS dan telemedicine',
  26. weaknesses: 'Customisasi sulit',
  27. website: 'https://simrsplatinum.id',
  28. },
  29. {
  30. name: 'Hospicare System',
  31. name_pt: 'PT Hospicare Nusantara',
  32. strengths: 'Stabil dan dokumentasi lengkap',
  33. weaknesses: 'Kurang inovatif',
  34. website: 'https://hospicare.co.id',
  35. },
  36. ];
  37. // Insert vendor dengan created_by dari adminUser.id
  38. for (const vendor of vendors) {
  39. await prisma.vendor.create({
  40. data: {
  41. ...vendor,
  42. created_by: adminUser.id,
  43. },
  44. });
  45. }
  46. console.log('✅ Vendor seeded!');
  47. } catch (error) {
  48. console.error('❌ Error seeding vendor:', error);
  49. }
  50. }
  51. module.exports = { seedVendors };