You'll be extending this project management app. The app uses Node.js, Express.js (framework), MySQL (database), ORM, and Handlebars (templating).
You'll be
-
adding in delete links for tasks and people. But only if the user is logged in.
-
adding in the appropriate route for the delete to work.
-
If a person gets deleted, cascade the delete to extend to the tasks that the person owns.
-
this is what the main page should look like if a user is signed in:
- you'll also add in this functionality:
- when clicking a person on the front end, it will take you to a profile for the person showing all the tasks for that person. In addition, you'll be able to edit the person's name and update the person's name. Upon updating, it will redirect you back to this person's profile.
- After complete The profile page will look like this:
- when clicking a person on the front end, it will take you to a profile for the person showing all the tasks for that person. In addition, you'll be able to edit the person's name and update the person's name. Upon updating, it will redirect you back to this person's profile.
This repository demonstrates the usage of sequelize within an express application.
The implemented logic is a simple task tracking tool.
- create a database called projects_db
mysql -u root
create database projects_db;
-
Adjust the
config/config.json
to fit your environment. -
install modules in package.json
npm install
- start up the app
nodemon start
if you don't have nodemon
npm start
- then in the browser go to http://localhost:3000
The following parts are for your own knowledge. You don't need to do this to setup the app. BUT WILL NEED TO INSTALL SEQUELIZE TO RUN THESE COMMANDS.
- Want to create a migration:
sequelize migration:create create-<table name here>
edit the migration file
to run the migration file:
sequelize db:migrate
You'll still have to make the model file in the models folder
-
curious of all the commands you can do with sequelize cli? go here: https://github.com/sequelize/cli
-
curious of all the sequelize relationships: http://docs.sequelizejs.com/en/latest/docs/associations/
-
In order to associate the models with each other, we changed the models like this:
// task.js
// ...
classMethods: {
associate: function(models) {
Task.belongsTo(models.Person);
}
}
// ...
// person.js
// ...
classMethods: {
associate: function(models) {
Person.hasMany(models.Task)
}
}
// ...