Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done! You have completed Using Sequelize ORM With Express !
You have completed Using Sequelize ORM With Express !
Preview
You will use the Sequelize ORM and Express to build a simple CRUD application that's connected to a SQL database. You will use Sequelize methods to perform CRUD operations within Express routes (using HTTP methods like get and post) to manage the data in the database.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC] 0:00
Hi everyone, Gil here, a JavaScript instructor at Treehouse. 0:09
In previous lessons, you learned how to use the Sequelize ORM to 0:12
interface with sequel based databases within a Node JS application. 0:15
You also learned how to work with the Express Web application framework for 0:20
Node to build dynamic web applications. 0:24
In this workshop, 0:26
you will bring together much of what you've learned about Sequelize and 0:27
Express to build a simple CRUD application that is connected to a Sequel database. 0:30
You will use the method Sequalize provides to perform CRUD operations within Express 0:35
routes using HTTP methods like Get and Post to manage the data and the database. 0:38
In addition, you'll work with the sequelize/cli a helpful command line 0:43
interface for sequelize to initialize all the configuration code, 0:47
folders and helpers needed for the application. 0:51
The project you will build and this workshop is a simple blog application, 0:53
it's going to have a page that lists all the articles, 0:58
a create article page an edit article page as well as a way to delete an article. 1:02
So we're essentially performing all the CRUD or create, read, update and 1:07
delete operations using a web interface. 1:10
And you'll be able to apply what you learn while building this project to just about 1:13
any node or express and sequel application you create moving forward. 1:16
To get started and code along with me, download the project files with this video 1:20
and open the starter files in your favorite text editor. 1:24
I'm using Visual Studio Code. 1:26
Once you open the starter files, run the command MPM install in your terminal or 1:28
console to install all the project dependencies. 1:33
After the dependencies finished downloading and 1:37
installing, run, MPM start to start the application. 1:39
And you can view the app in the browser on localhost port 3000. 1:44
So this is the beginning state of the blog application. 1:47
To get it started, I used the express application 1:51
generator tool to create the express app which I then modified. 1:54
The express generator is a command line tool that makes it easy to start new apps. 1:57
It sets up much of the boolar plain code needed to build an express 2:02
app like starting a new server instance, 2:05
configuring a view engines, setting up air handling and more. 2:07
The structure of the generated express application contains folders such as bin, 2:10
public, routes and views which you will learn about as you build the application. 2:14
You're can learn more about the express generator tool and 2:18
its helpful command options in the teachers notes with this video. 2:21
The focus of this workshop in on Sequelize, 2:24
so we're going to work on connecting to a data base from the express app and 2:26
write all the data base calls within the route handler functions. 2:30
I've already included all the view templates inside the views folder, and 2:33
starter code to handle the routes inside the routes folder. 2:37
For example, the app uses the pug 2:41
templating engine to generate all the views. 2:44
And the articles.js file inside the routes folder, holds all the routes to create, 2:47
read, update and delete articles in the app. 2:52
Both the index and articles routes are imported into app.js, 2:54
then passed to the Express app via these app.use methods. 3:00
We'll add more inside the route handlers as we implement the database code. 3:03
Before moving on to the next step, go ahead and 3:08
familiarize yourself with the routes and views. 3:10
Once you're ready, you'll start by setting up and 3:13
connecting to a sequel lite database. 3:15
To be successful in this workshop that you should be familiar with using 3:17
the Sequelize ORM as well as the Express framework and 3:20
the async await syntax for working with promises. 3:25
So be sure to review the teachers notes with this video if you need a refresher on 3:28
any of these topics. 3:31
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up