npm i sequelize mysql2 -S
npm i sequelize-cli -D
npx sequelize init
config.json에서 password와 host교체(엔드포인트)
npx sequelize db:create를 실행하면 conpig.json에 있는 database의 값을 실행한다
conpig/conpig.json 을 찾는다.
만약, cjs로 바꾼다면, npx sequelize db:create --config config/config.cjs
로 실행하면 된다.
데이터베이스 생성(config.json)
npx sequelize db:create
생성 가능..?
npx sequelize model:generate --name Products --attributes title:string,content:string,status:string
// migrations와 models에 만들어준다.
유저 스키마 생성
npx sequelize db:migrate
데이터베이스에 값 생성
npm run resetdb
TABLE을 새로 한다.
npx sequelize db:drop && npx sequelize db:create && npx sequelize-cli db:migrate
npm run resetdb를 실행하는데
error: type is not a constructor 에러가 나온다.
migrations에서 import를 안해줘서 그럼
/* @type {import('sequelize-cli').Migration} /
package.json에서 scripts를 만들고
dev: nodemon app.js하면 dev로 갈아낌
npm run dev
테이블과 모델 라우트 웬만하면 이름 같게하자