Prisma Dmmf TransformerInstallation

Installation

Last updated:

Installation

Install the Prisma DMMF transformer using your preferred package manager:

npm install @visulima/prisma-dmmf-transformer

Peer Dependencies

This package requires Prisma:

npm install @prisma/client @prisma/generator-helper

Import

import { transformDMMF, getJSONSchemaProperty } from "@visulima/prisma-dmmf-transformer";

CommonJS

const { transformDMMF } = require("@visulima/prisma-dmmf-transformer");

Requirements

  • Node.js: 18.x or higher
  • Prisma: 3.10.0 or higher
  • TypeScript: 5.0 or higher (for TypeScript projects)

Prisma Setup

Ensure you have a Prisma schema:

// prisma/schema.prisma
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

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

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

Generate Prisma Client:

npx prisma generate

Verification

Verify your installation by transforming DMMF:

import { PrismaClient } from "@prisma/client";
import { transformDMMF } from "@visulima/prisma-dmmf-transformer";

const prisma = new PrismaClient();

// Access internal DMMF
const dmmf = await (prisma as any)._getDmmf();

// Transform to JSON Schema
const schema = transformDMMF(dmmf);

console.log(Object.keys(schema.definitions));
// Output: ['User', 'Post']
Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues