> For the complete documentation index, see [llms.txt](https://asamarsal.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://asamarsal.gitbook.io/notes/personal-documentation/express-js-+-prisma-+-typescript/seeder.md).

# Seeder

```typescript
import { PrismaClient } from '../src/generated/prisma';

const prisma = new PrismaClient();

async function main() {
    await prisma.product.deleteMany({});

    const products = [
        {
          name: "Basreng",
          price: 500,
          stock: 20
        },
        {
          name: "Cilok", 
          price: 1000,
          stock: 40
        },
        {
          name: "Sate",
          price: 2000,
          stock: 50
        }
      ];

    for (const product of products) {
        await prisma.product.create({
          data: product
        });
    }
    
      console.log('Seeding completed!');
}

main()
    .catch((e) => {
        console.error(e);
        process.exit(1);
    })
    .finally(async () => {
        await prisma.$disconnect();
    });
```
