From the course: Databases for Node.js Developers
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Setting up the database connection - Node.js Tutorial
From the course: Databases for Node.js Developers
Setting up the database connection
- [Instructor] To start using Sequelize with MySQL, we first need to install the necessary packages. So I already opened my terminal, I terminated our application, and now I type npm install sequelize, and also, mysql2. This install Sequelize, the ORM we'll use to interact with the database, and mysql2, the driver Sequelize uses to connect to MySQL. Now I will start my app again by running npm run dev. And with these installed, we are ready to set up the database connection in our Fastify application. And you will see that it's fairly similar to what we did with MongoDB, and that's a good sign because this means that we are consistent in the way we are doing things. So what we will do here is we will connect Fastify to MySQL by completing the Sequelize plugin that is already in our project. This plugin will handle connecting to MySQL using Sequelize and make the connection available across the app. But before we do this, and that's, again, similar to what we did with MongoDB, I go…
Contents
-
-
-
-
-
-
(Locked)
Using MySQL for our users and orders1m 8s
-
(Locked)
Setting up MySQL with Docker2m 49s
-
(Locked)
Exploring MySQL with MySQL Workbench1m 57s
-
(Locked)
Introducing Sequelize1m 51s
-
(Locked)
Setting up the database connection7m 43s
-
(Locked)
Designing the database structure2m 1s
-
(Locked)
Creating a user model for Sequelize7m 47s
-
(Locked)
Creating the order models for Sequelize11m 56s
-
(Locked)
Loading and syncing the models13m 5s
-
(Locked)
Creating, updating and deleting users with Sequelize12m 52s
-
(Locked)
Securing credentials with password hashing7m 2s
-
(Locked)
Implementing the user login9m 15s
-
(Locked)
-
-
-