• Stars
    star
    567
  • Rank 78,634 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easy Prisma support for your NestJS application

nestjs-prisma

Easy Prisma support for your NestJS application.

Build Status Total Downloads npm package License

Installation

Automatic Install

Use the nest add command to automatically setup the library, Prisma and Docker (optionally):

nest add nestjs-prisma

Manual Install

Add nestjs-prisma library to your NestJS application:

# npm
npm install nestjs-prisma

# yarn
yarn add nestjs-prisma

Furthermore, setupΒ Prisma in your NestJS application, if you haven't already.

npm i -D prisma
npm install @prisma/client

npx prisma init

Basic usage

Add PrismaModule to the imports section in your AppModule or other modules to gain access to PrismaService.

import { Module } from '@nestjs/common';
import { PrismaModule } from 'nestjs-prisma';

@Module({
  imports: [PrismaModule.forRoot()],
})
export class AppModule {}

Use the PrismaService via dependency injection in your controller, resolver, services, guards and more:

import { Injectable } from '@nestjs/common';
import { PrismaService } from 'nestjs-prisma';

@Injectable()
export class AppService {
  constructor(private prisma: PrismaService) {}

  users() {
    return this.prisma.user.findMany();
  }

  user(userId: string) {
    return this.prisma.user.findUnique({
      where: { id: userId },
    });
  }
}

You have access to all exposed methods and arguments of the generated PrismaClient through PrismaService.

Documentation

Visit our official documentation.

Contributing

You are welcome to contribute to this project.

The code is split up into three directories:

+-- docs
+-- examples
+-- lib
+-- schematics

The docs directory contains an astro website and the docs content.

The examples directory contains example applications.

The lib directory contains everything exposed by nestjs-prisma as a library.

The schematics directory contains the blue prints for installing the library with the schematic command.

Here are some tips if you like to make changes to the schematics.

Install @angular-devkit/schematics-cli to be able to use schematics command

npm i -g @angular-devkit/schematics-cli

Now build the schematics and run the schematic.

npm run build:schematics
# or
npm run dev:schematics

# dry-run
schematics .:nest-add

# execute schematics
schematics .:nest-add --debug false
# or
schematics .:nest-add --dry-run false

Helpful article about Custom Angular Schematics which also applies to Nest.

More Repositories

1

nestjs-prisma-starter

Starter template for NestJS 😻 includes GraphQL with Prisma Client, Passport-JWT authentication, Swagger Api and Docker
TypeScript
2,287
star
2

prisma-dbml-generator

Prisma DBML Generator
TypeScript
636
star
3

ngx-tailwind

πŸ’¨ Simple Angular schematic that initializes Tailwind CSS in your project and adds a custom webpack config to your build process.
TypeScript
128
star
4

nestjs-prisma-docker

Dockerizing a NestJS app with Prisma and PostgreSQL
TypeScript
93
star
5

notiz

Frontend for notiz.dev. Built with Angular and Scully πŸ‘‹
TypeScript
68
star
6

nestjs-mailer

Send Emails with NestJs
Handlebars
57
star
7

github-action-json-property

β˜•Simple GitHub Action to read a specified property from a JSON file.
TypeScript
32
star
8

scully-plugins

Scully plugins (fouc, lazy-images, rss, medium-zoom)
TypeScript
22
star
9

nestjs-swagger

NestJS with OpenApi Swagger documentation
TypeScript
16
star
10

floating-form-field-tailwindcss

Floating Form Field using Tailwind CSS
HTML
15
star
11

notiz-api

Notiz Api
Handlebars
9
star
12

cookiemonster

A customizable Cookie Consent Banner for Angular. Built with Tailwind. GDPR & EU ready!
TypeScript
7
star
13

ngx-plausible

Plausible Event directive for Angular
TypeScript
6
star
14

angular-scully-tailwindcss

Jamstack Angular app with Scully and styled with Tailwind CSS
TypeScript
5
star
15

nest-graphql-code-first

Nest Graphql Code First approach
TypeScript
4
star
16

nestjs-prisma-demo

How to query your database using Prisma with Nestjs
TypeScript
4
star
17

ngx-markdoc

Markdoc for Angular
TypeScript
3
star
18

angular-tailwindcss

Learn how to style Angular applications Tailwind CSS
TypeScript
3
star
19

deploy-nestjs-prisma-heroku

Deploy a Nestjs application with Prisma 2 to Heroku and connect to a PostgreSQL database
TypeScript
3
star
20

design

Design for notiz.dev
TypeScript
2
star
21

github-action-template

Simple Typescript GitHub Action Start Template
TypeScript
2
star
22

ngx-gravatar-url

Gravatar Url Pipe for Angular
TypeScript
2
star
23

codegen-angular-nest

TypeScript
1
star