- | |
---|---|
database name | lowercase with words separated by underscores |
table name | lowercase with words separated by underscores (singular) |
properties | lowercase with words separated by underscores |
foriegn keys | tableName_propertyName |
This is a starter project that you can use as a NestJS template with Prisma
- Clone the repo
$ git clone [email protected]:OsidAbu-alrub/nestjs-prisma-template.git
- Change origin url to point to your own repo
$ git remote set-url origin <remote_url>
- Install deps
$ yarn install
# development
$ yarn dev
This structure must come under the src directory:
- resource/
- resource.contract.ts => interface that contains methods that should be implemented in the resource.service file
- resource.controller.ts
- resource.dto.ts
- resource.module.ts
- resource.service.ts => must implement resource.contract interface
P.S. You get models from prisma client after generating database
you can find how to generate nestjs resources here
# Create migrations from your Prisma schema, apply them to the database, generate artifacts (e.g. Prisma Client)
$ npx prisma migrate dev --name init
# Pull the schema from an existing database, updating the Prisma schema
$ npx prisma db pull
# Push the Prisma schema state to the database
$ npx prisma db push
$ npx prisma generate
reload developer window if you are using vscode to access prisma client
For more info you could check prisma docs here
Coming Soon!
- Add global error filtering
- Add ability to generate folder with contract, controller, dto, module, and service with package.json scripts (use blobs)
- Add documentation for db generation commands