Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 745 Bytes

README.md

File metadata and controls

45 lines (32 loc) · 745 Bytes

Basics

NestJS app with Express, Prisma and nestjs-prisma.

Adjust prisma/schema.prisma and perform a migration:

npx prisma migrate dev

Seed the example database:

npx prisma db seed

Start the Nest app and open localhost:3000.

npm i

npm run start:dev

Use PrismaService to access the type-safe generated PrismaClient.

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 },
    });
  }
}