A quick review of connecting a MySQL database to our Express server
npm install
npm run start
This repo is recommended to be used with MySQL 5.7
.
- Create database
ReviewDB
within MySQL - Establish connection to database in
database/index.js
- Create a schema in
database/schema.sql
to describe ourtasks
table - Run schema file in terminal
- Create a seeding function in
database/seed.js
to populate table with at least 5 records - Run seed file in terminal
- Create dbHelper functions in
database/dbHelpers.js
- Create controller functions in
server/controllers.js
- Use dbHelper functions within your controller functions
- Test for working functionality via Postman
Refactor the following files to utilize Sequelize ORM:
database/index.js
database/dbHelpers.js
server/controllers.js
NOTE: You may need to create an additional database/model.js
to allow Sequelize to define our tasks
table model