Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • PrismaPostgres Documentation40টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Prisma Intro
  • Prisma vs Raw SQL
  • Setup & Install
  • Schema Basics
  • Models
  • Relations
  • Migrations
  • Prisma Client
  • Create & Upsert
  • Read Queries
  • Update & Delete
  • Query Filters
  • Sort & Pagination
  • Select & Include
  • Nested Writes
  • Transactions
  • Aggregation
  • JSON Fields
  • Raw SQL
  • TechShop Schema
  • TechShop Seed
  • Relations Advanced
  • Env Config
  • Global Client
  • Next.js + Prisma
  • Express API
  • Error Handling
  • Performance
  • Connection Pool
  • Prisma Studio
  • Deploy Migrations
  • TechShop Indexes
  • TechShop Cart
  • TechShop Stats API
  • Schema Evolution
  • Debugging
  • Common Mistakes
  • Best Practices
  • Interview Questions
  • Recap & Next
  1. Docs
  2. PrismaPostgres
  3. Seed — ডিজাইন ডেটা দিয়ে begin
PrismaPostgresIntermediate

Seed — ডিজাইন ডেটা দিয়ে begin

dev DB-তে sample data — categories, products, users।

4টি অংশবাংলা ভাষায়
prisma/seed.tsts
ts
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

async function main() {
  const [tech, lifestyle] = await Promise.all([
    prisma.category.upsert({
      where: { name: "Tech" },
      update: {},
      create: { name: "Tech" },
    }),
    prisma.category.upsert({
      where: { name: "Lifestyle" },
      update: {},
      create: { name: "Lifestyle" },
    }),
  ]);

  await prisma.product.createMany({
    data: [
      { name: "Mechanical Keyboard", price: 4200, qty: 10, categoryId: tech.id },
      { name: "Wireless Mouse", price: 1800, qty: 25, categoryId: tech.id },
      { name: "Desk Lamp", price: 1200, qty: 15, categoryId: lifestyle.id },
    ],
  });
}

main()
  .catch((e) => { console.error(e); process.exit(1); })
  .finally(() => prisma.$disconnect());
package.json + চালানোbash
bash
// package.json
"prisma": {
  "seed": "tsx prisma/seed.ts"
}

npx prisma db seed
  • seed idempotent — upsert ব্যবহার
  • tsx বা ts-node — TypeScript seed
  • migrate reset --force → auto seed
বড় seed

বড় data-তে loop এড়িয়ে createMany — Controller-area আরো পরে।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরTechShop — সম্পূর্ণ Prisma schemaপরেরমতভাবে relation — explicit N:M, self-relation
Tech Tutor

বাংলায় ওয়েব ডেভেলপমেন্ট ডকুমেন্টেশন শিখুন — ধাপে ধাপে।

Homeসব ডকুমেন্টেশনQuick Startআমার নোটস

© 2026 Tech Tutor. বাংলায় শিখুন, বাংলায় গড়ুন।

mdanamolhasan1998@gmail.com