express と sequelize を連携させる最小のアプリケーションを作成
こちらを参考にしました。
2020/01/05 に試してみました。
2020/02/02 に vulnerability のセキュリティーエラーに対応しました。
npx express-generator
npm install
npm i sequelize sequelize-cli
npx sequelize-cli init
npm i pg pg-hstore
npx sequelize-cli initで生成される「config/config.json」ファイルは含まれていません。各自の環境に合わせて編集する必要があります。
npm i pg pg-hstoreは私が構築した環境に postgres が存在したことと利用実績があるためです。各自の環境に合わせて必要なモジュールをインストールしてください。
npx sequelize-cli model:generate --name User --attributes username:string
npx sequelize-cli model:generate --name Task --attributes title:string
npx sequelize-cli db:migrate
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.