Create your own Sequelize-Template.
- Create a new local MYSQL database called 'todolist', but don't create any tables.
- Notice how there are no config or models folders?
- In terminal, run
npm i
- In terminal, run
npm i --save-dev sequelize-cli
- In terminal, run
npm i -g npx
(You'll only have to do this once, ever, on this machine). - In terminal, type in the following commands (hit enter after each):
npx sequelize init:models
npx sequelize init:config
- Step 6 should have created a config and a models folder for us. Navigate to the config folder, open
config.json
, and modify as per instructor's instructions to use .env file. - Navigate to the models folder and create a new file called
todo.js
. Along with instructor, create a Todo model with columns for "text" (DataTypes.STRING), and "complete" (DataTypes.BOOLEAN). - Navigate to the server.js file and require all of our models by requiring the models folder. Save this to a variable and name it "db".
- Sync the models by running db.sequelize.sync() after we start the express server.
- In your terminal, run
npm run watch
. Check MYSQL Workbench to see if a Todos table was created. If so, you were successful. If not, check your terminal for any errors. - Now let's complete the
routes/api-routes.js
file to make the app work.
- Sequelize
- JavaScript
- Api Routes
- 📁 .vscode
- 📄 launch.json
- 📄 settings.json
- 📁 config
- 📄 config.json
- 📁 models
- 📄 index.js
- 📄 todo.js
- 📁 public
- 📁 css
- 📄 style.css
- 📁 js
- 📄 view.js
- 📄 api-routes.js
- 📁 css
- 📄 .DS_Store
- 📄 .eslintc.js
- 📄 .gitignore
- 📄 .jsdoc.json
- 📄 README.md
- 📄 package-lock.json
- 📄 package.json
- 📄 schema.sql
- 📄 server.js
🌎 Coming soon!