Exercise 1: A First CRUD Script — Possible Solution ===================================================== // crud.ts import { prisma } from "./lib/prisma"; // Start clean so the script can be re-run (slugs are unique) await prisma.post.deleteMany({}); const created = await prisma.post.createMany({ data: [ { title: "Getting started", slug: "getting-started" }, { title: "Schema basics", slug: "schema-basics" }, { title: "Migrations", slug: "migrations" }, ], }); console.log(`Created ${created.count} posts`); await prisma.post.update({ where: { slug: "getting-started" }, data: { published: true, publishedAt: new Date() }, }); const drafts = await prisma.post.count({ where: { published: false } }); console.log(`Drafts: ${drafts}`); const titles = await prisma.post.findMany({ select: { title: true } }); console.log(titles.map((p) => p.title)); await prisma.$disconnect(); Output: $ npx tsx crud.ts Created 3 posts Drafts: 2 [ 'Getting started', 'Schema basics', 'Migrations' ] Then run `npx prisma studio`, open the Post table, and you'll see the three posts, with "Getting started" marked published and given a publishedAt date. WHY THIS WORKS AS AN ANSWER ------------------------------ It uses create, update, count and a select-only read in one short script. The deleteMany at the start makes it safe to run more than once — without it, the second run would fail with a P2002 duplicate slug error. (Don't do that on data you care about!)