Skip to content

Latest commit

 

History

History
89 lines (70 loc) · 1.96 KB

run_guide.md

File metadata and controls

89 lines (70 loc) · 1.96 KB
cd projects/learning/11_nestjs
docker ps
docker kill $(docker ps -q)
docker build -t nest-cloud-run .
docker run -p80:3000 nest-cloud-run

visit: 0.0.0.0

Player json examples

{ "name": "samBender", "isNational": false, "joiningDate": "2023-03-06", "role": ["wicketkeeper", "baller"] }

Team json examples

{ "name": "India", "description": "best team in the world", "players": [{ "name": "Virat Kohli", "isNational": true, "joiningDate": "2023-03-01", "role": ["captain", "batsman"]}, { "name": "Rahul Dravid", "isNational": false, "joiningDate": "2023-03-06", "role": ["batsman", "baller"] }] }

vscode tricks

https://stackoverflow.com/questions/50028649/multiline-column-copy-paste-in-vs-code

npx prisma init --datasource-provider postgresql
npx prisma db pull
npx prisma validate
sudo docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres

in .env : DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"

npx prisma migrate dev
npx prisma migrate reset
npx prisma db seed
npm install prisma --save-dev
npx prisma init --datasource-provider postgresql
npm i @prisma/client
npx prisma db seed
npx prisma studio
npx nest generate module prisma
npx nest generate service prisma
npm install --save @nestjs/swagger swagger-ui-express

go to localhost:3000/api

npx nest generate resource

add: imports: [PrismaModule] to: module

add: constructor(private prisma: PrismaService) {} to: service

add the dto

change the controller and services

Data models

https://www.prisma.io/docs/concepts/components/prisma-schema/data-model

Data base migration issues

npx prisma migrate diff --from-url "postgresql://postgres:postgres@localhost:5432/mydb?schema=public" --to-schema-datamodel prisma/schema.prisma --script > forward.sql npx prisma db execute --url "postgresql://postgres:postgres@localhost:5432/mydb?schema=public" --file forward.sql