fuji44
MCP Serverfuji44public

deno prisma esm tutorial

This is a very simple tutorial on how to generate an ESM format client in Prisma and use it with deno.

Repository Info

5
Stars
0
Forks
5
Watchers
0
Issues
TypeScript
Language
-
License

About This Server

This is a very simple tutorial on how to generate an ESM format client in Prisma and use it with deno.

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

deno-prisma-esm-tutorial

Prisma can now generate an ESM version of the client, so let's use it with Deno.

$ deno --version
deno 2.2.12 (stable, release, x86_64-unknown-linux-gnu)
v8 13.5.212.10-rusty
typescript 5.7.3

Tutorial

First, install the Prisma libraries.

deno add npm:prisma npm:@prisma/client

Then run prisma init.

deno run -A npm:prisma init --datasource-provider sqlite --generator-provider prisma-client --with-model

Open the generated schema.prisma and set moduleFormat to esm. provider and moduleFormat are important.

  generator client {
    provider     = "prisma-client"
    output       = "../src/generated/prisma"
+   moduleFormat = "esm"
  }

  datasource db {
    provider = "sqlite"
    url      = env("DATABASE_URL")
  }

  model User {
    id    Int     @id @default(autoincrement())
    email String  @unique
    name  String?
  }

Initialize the database.

deno run -A --env-file npm:prisma migrate dev --name init

Create a script to add a User and one to list Users, then run them:

$ deno run -A --env-file src/createUser.ts
{ id: 1, email: "user481@example.com", name: "user481" }
$ deno run -A --env-file src/createUser.ts
{ id: 2, email: "user396@example.com", name: "user396" }
$ deno run -A --env-file src/listUsers.ts
[
  { id: 1, email: "user481@example.com", name: "user481" },
  { id: 2, email: "user396@example.com", name: "user396" }
]

It works without issues.

Next, try migrations by adding a Post model.

...

  model User {
    id    Int     @id @default(autoincrement())
    email String  @unique
    name  String?
+   posts Post[]
  }

+ model Post {
+   id        Int     @id @default(autoincrement())
+   title     String
+   content   String?
+   published Boolean @default(false)
+   author    User    @relation(fields: [authorId], references: [id])
+   authorId  Int
+ }

Run the migration.

WARNING

This appears to be a bug, but if client code already exists, the code generation fails. For now, remove the existing generated code before running prisma migrate or prisma generate.

$ rm -rf src/generated/
$ deno run -A --env-file npm:prisma migrate dev --name add-post-model

Create a script to add a Post and one to list them, then run them:

$ deno run -A --env-file src/createPost.ts
{
  id: 1,
  title: "Post Title 137",
  content: "This is the content of Post Title 137",
  published: true,
  authorId: 1
}
$ deno run -A --env-file src/createPost.ts
{
  id: 2,
  title: "Post Title 347",
  content: "This is the content of Post Title 347",
  published: true,
  authorId: 1
}
$ deno run -A --env-file src/listPostsByUser.ts 
[
  {
    id: 1,
    title: "Post Title 137",
    content: "This is the content of Post Title 137",
    published: true,
    authorId: 1
  },
  {
    id: 2,
    title: "Post Title 347",
    content: "This is the content of Post Title 347",
    published: true,
    authorId: 1
  }
]

It also runs without problems.

Reference

  • https://www.prisma.io/blog/prisma-orm-6-6-0-esm-support-d1-migrations-and-prisma-mcp-server#esm-support-with-more-flexible-prisma-client-generator-early-access
  • https://www.prisma.io/docs/orm/prisma-schema/overview/generators#prisma-client-early-access

Quick Start

1

Clone the repository

git clone https://github.com/fuji44/deno-prisma-esm-tutorial
2

Install dependencies

cd deno-prisma-esm-tutorial
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerfuji44
Repodeno-prisma-esm-tutorial
LanguageTypeScript
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation