A quick review of connecting a MySQL database to our Express server
npm install
npm run connect *** verify db connection
npm run start
This repo is recommended to be used with MySQL 5.7.
- MySQL: MySQL Github documentation
- Create database
foodDBwithin MySQL - Establish connection to database in
database/index.js
- Create a schema in
database/schema.sqlto describe ourfoodtable - Run schema file in terminal
- Create a seeding function in
database/seed.jsto 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 - Create routes in
server/router.js - Use dbHelper functions within your controller functions
- Test for working functionality via Postman
Express is a routing and middleware web framework that has minimal functionality of its own: An Express application is essentially a series of middleware function calls.
