이번 강의에서는 노마드가 Prisma 를 사용한다고 한다
기존에는 ORM 중 typeorm 을 사용했고 이것도 엄청 편리하다고 생각하고 있던 중이었지만 노마드가 Prisma 2 가 나오면서 엄청나다고 하여 이번 기회에 강의를 보며 공부를 하면 좋을 거 같다🧐
언어 typescript, javascript
SQL PostgreSQL, MySQL
위와 같이 지원하는 거 같고 Go lang, MsSQL 을 준비하는 걸로 보인다
npm install prisma -D
npx prisma init
prisma:warn @prisma/cli has been renamed to prisma.
Please uninstall @prisma/cli: npm remove @prisma/cli
And install prisma: npm i --save-dev prisma
✔ Your Prisma schema was created at prisma/schema.prisma.
You can now open it in your favorite editor.
(...생략)
More information in our documentation:
https://pris.ly/d/getting-started
npm i @prisma/cli -D
를 했지만 해당 로그를 보니 모듈 이름이 바뀐듯 하여 npm uninstall @prisma/cli
하고 npm i --save-dev prisma
를 하여 다시 설치했다🤗MAC을 사용한다면 homebrew 을 통해 쉽게 설치 가능
brew install postgres
psql –U postgres –d postgres
postgres 가 디폴트로 알고 있다
안된다면 구글링을 활용하자😏
CREATE DATABASE prismatest
psql –U postgres –d prismatest
로 접속이 된다면 정상적으로 생성이 된거다quit, exit 를 사용하면 db에서 빠져나올 수 있다
DATABASE_URL="postgresql://postgres:randompassword@localhost:5432/prismatest?schema=public"
사진과 같이 Movie model을 추가한다
npx prisma migrate dev
migration.sql 폴더에는 Movie 생성 쿼리문이 들어있다
\dt
를 입력하여 테이블 리스트 확인