nestjs-prisma
Automation

Schematics

Command

The schematics command automatically performs additional steps to configure Prisma and Docker in your project.

  • Initialize Prisma npx prisma init --datasource-provider postgres|...
  • Add Prisma npm scripts to your package.json
  • Add seed script for Prisma
  • Generate custom PrismaService and PrismaModule (optionally)
  • Add Dockerfile and docker-compose.yml (optionally)
  • Excludes prisma directory from build via tsconfig.build.json

Example output of the schematics:

 Package installation in progress...
Starting library setup...
? Which datasource provider do you want to use for `prisma init`? postgresql
? Do you like to Dockerize your application? (Supports postgresql and mysql) Yes
    ✅️ Added prisma@latest
    ✅️ Added @prisma/client@latest
    ✅️ Added Prisma scripts [6]
    ✅️ Added Prisma Seed script
    ✅️ Added Docker file
    ✅️ Added Docker Compose and .env
    ✅️ Add "prisma" directory to "excludes" in tsconfig.build.json
CREATE .dockerignore (42 bytes)
CREATE Dockerfile (455 bytes)
CREATE .env (642 bytes)
CREATE docker-compose.yml (497 bytes)
UPDATE package.json (2754 bytes)
UPDATE tsconfig.build.json (130 bytes)
 Packages installed successfully.
 Packages installed successfully.
    ✅️ Initialized Prisma - Datasource postgresql

Options

All available options to passe to the schematic command:

FlagDescriptionTypeDefault
datasourceProviderSpecifies the datasource provider for prisma init and docker.booleanPrompted
addDockerCreate a Dockerfile and docker-compose.yaml.booleanPrompted
addPrismaServiceCreate a Prisma service extending the Prisma Client and module.booleanfalse
dockerNodeImageVersionNode version for the builder and runner image.string14
nameThe name for the Prisma service extending the Prisma Client and module.stringPrisma
prismaVersionThe Prisma version to be installed.stringlatest
skipInstallSkip installing dependency packages.booleanfalse
skipPrismaInitSkip initializing Prisma.booleanfalse

You can pass additional flags to customize the schematic. For example, if you want to install a different version for Prisma use --prismaVersion flag:

nest add nestjs-prisma --prismaVersion 3.2.1

If you want to skip installing dependencies use --skipInstall flag:

nest add nestjs-prisma --skipInstall

Add Dockerfile and docker-compose.yaml, you can even use a different node version (14-alpine or 16).

Currently uses PostgreSQL as a default database in docker-compose.yaml.

nest add nestjs-prisma --addDocker --dockerNodeImageVersion 14-alpine