@@angelbythewings yep, i explained that in the past hahaha i used to call it required and response because thats how i said (in order to understand) back when i was learning. I shouldn’t have used that in the video but when i made this video i was grtting like 3 views per video so i didnt think it would matter hahaha nowadays i say request in my new videos
@@angelbythewings nahhh its good hahahha i really appreciate it cause other people can see it! I sometimes don’t like my old videos cause im scared that i used to say dumb stuff like this lmao
11:50 req does not mean "require", it means "request", the req and res in (req, res) => {...} literally means request and response 13:55 that if(err) is redundant, the .catch() is called only if err is thrown... the only useful thing to do with conditionals inside the .catch() is handling different kinds of errors
when i write sequelize init i get an error The term 'sequelize' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + sequelize init + ~~~~~~~~~ + CategoryInfo : ObjectNotFound: (sequelize:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PLEASE HELP
nvm, i found the solution, sequelize init imports it wrong for the models. It should be like this: const { Sequelize } = require("sequelize"); Not like this: const Sequelize = require("sequelize");
What about connection to multiple databases? What's the best approach? Btw if you could make an updated version of this video it would be great because sequelize is a bit implementation is a bit different now.
Hi, I’m new to the Sequelize ORM utilities, but I imagine you would need to instantiate another instance of Sequelize and pass it your other databases’ configuration settings (i.e. name, port, password, username, etc.) The Sequelize instance in ./models/index.js in the video only creates one database object with its corresponding tables. Not sure how you would implement it using DBMS other than MySQL though. ps. Not sure if this is the best approach for making multiple database connections, or if this is even right at all, so take it with a grain of salt.
Why do we have to pass sequelize & DataTypes ad parameter in Models. Can't we directly import from sequelize ? like const { DataTypes, Sequelize } = require('sequelize');
You could do it both ways! Passing it as a parameter is a standard for the sequelize-cli, but if your not using it than you probably should just import it!
Thank you i learn a lot can you make it with front end an todo task application so that others can deep dive learn using with node js express pug integration
I have a an example of how to make a todo list application on my 3 part series called: CRUD Tutorial ReactJS ! I don't use sequelize on that series, but transferring the normal mysql logic to sequelize is pretty straightforward!
Hi Pedro, how are you? I have a question, is this way of doing queries safe? Is this the frontend interfacing with the db directly? Im not sure about those things. Thank you!
When I saw that you npm installed fs and path I realized you have no idea what you're talking about. These modules aren't packages. They are internal modules provided by nodejs itself. Thinking you need to install these demonstrates a great lack of experience with the platform.
You export your model function from User.js which is an anonymous function that takes 2 params - sequelize, DataTypes. I don't understand how when you then import this function as db you don't have to pass an instance of sequelize and Datatypes to it? How can you simply say db.sequelize.define (....) -- shouldn't you have to say db(sequelize, DataTypes).define ( ... ) ??
Hi great video, need your help in one question. I have two DBs in mysql. In DB1 we have person table and DB2 we have gender table. I have to do association between DB1.person and DB2.gender. can you help me with this.
It depends on what is your application. However in a Job or an advanced project, usually you would use Sequelize. Its a lot more handy to use an ORM like Sequelize because then you don't need to write actual SQL. It is a way to convert SQL to normal JavaScript, so thats why almost every company uses it.
hello, I got an error when I coding with your video. const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes); ^ TypeError: Class constructor model cannot be invoked without 'new'
i had to use this command on bash "powershell Set-ExecutionPolicy RemoteSigned" on VS to skip the problem "cannot be loaded because running scripts is disabled on this system."
I failed at step: sequelize init, return "sequelize : unrecognizable. previous step: npm install... seems ok with npm warning server@1.0.0 no description. help please
please zoom the screen or increase font size. ur screen is too big, does not mean that others have the same... if i watch it on mobile, the font is too small. barely reading
9:45 "You can see that its going to give an error" - How I always feel when I'm coding. Thanks for taking the time for this tutorial.
The difference between mysql and mysql2 is basically promises. The package mysql2 allows you to work with asynchronous JS. Thanks for the video bro.
Thanks for sharing! I actually never realized this. This can be helpful cause ive been caught in callback 'hell' situations using mysql.
very simple and straight to the point, not everyone needs 3 hours of video tutorial, nice video!
Concise and straight to the point! Beats these 3 hour crash course vids. Thanks for the tutorial.
Thank you! Really appreciate it!
@@PedroTechnologies Awesome tutorial and very straight to the point
Your videos helped me get an internship. I'm really grateful.
Wow thats amazingg! If you don't mind, where you going to work? This makes me very happy!
You didn’t need to install path and fs. They are built in node js modules
Yes
@@PedroTechnologies Also its not require, its request and response 😄
@@angelbythewings yep, i explained that in the past hahaha i used to call it required and response because thats how i said (in order to understand) back when i was learning. I shouldn’t have used that in the video but when i made this video i was grtting like 3 views per video so i didnt think it would matter hahaha nowadays i say request in my new videos
@@PedroTechnologies that's completely understandable. Sorry if you already knew, I shouldn't have pointed out.
BTW it was a very nice tutorial
@@angelbythewings nahhh its good hahahha i really appreciate it cause other people can see it! I sometimes don’t like my old videos cause im scared that i used to say dumb stuff like this lmao
bestest video in the whole worldd, i am saying you are the best, I have been searching everywhere but here my search got results, thankksssssss
11:50 req does not mean "require", it means "request", the req and res in (req, res) => {...} literally means request and response
13:55 that if(err) is redundant, the .catch() is called only if err is thrown... the only useful thing to do with conditionals inside the .catch() is handling different kinds of errors
Amazing tutorial sir!!... you cleared my doubts regarding sequelize in one go 👍👍
Glad to hear that
Another really great run-down on a topic! Thanks!
Glad you enjoyed it!
You can also use Postman to test different methods like post without frontend at all 14:40
Please can you do a tutorial on Table relationship? Really need that with sequelize
Some people requested this, I plan on doing it!
Need it !
Yes please
yes please
Beautiful and most required video 🙏
Honestly it was very well explained ❤.
Really Helpful. Thanks for the great tutorial !
Glad it was helpful!
That was a really good explanation!
Glad you liked it!
i really appreciate your effort... it was very usefull for me
Glad it was helpful!
when i write sequelize init i get an error The term 'sequelize' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ sequelize init
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (sequelize:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PLEASE HELP
am also getting same error
npm install -g sequelize-cli
I have the same error, you have to use "npx sequelize-cli init"
This is great, so I glad I found your video :D
Love you bro thanks a lot it is best way to learn for beginners
Thank you for this helpful tutorial!
Thanks for the video Pedro!
An excellent introduction to using Sequilize to perform CRUD Operations on a mySQL database. Thanks, Pedro
{2023-06-05}
Thanks for the videos, i have a question. Is there a library for autocompleting sequelize syntax? I tried a few but they don't seem to work.
nvm, i found the solution, sequelize init imports it wrong for the models.
It should be like this:
const { Sequelize } = require("sequelize");
Not like this:
const Sequelize = require("sequelize");
Awesome! Yeah, they are exporting Sequelize as a separate variable so to get the autocomplete you have to put the brackets. Glad you fixed it!
this was very helpful! thank you
thank you sir, useful and easy to understand
What about connection to multiple databases? What's the best approach?
Btw if you could make an updated version of this video it would be great because sequelize is a bit implementation is a bit different now.
Hi, I’m new to the Sequelize ORM utilities, but I imagine you would need to instantiate another instance of Sequelize and pass it your other databases’ configuration settings (i.e. name, port, password, username, etc.) The Sequelize instance in ./models/index.js in the video only creates one database object with its corresponding tables. Not sure how you would implement it using DBMS other than MySQL though.
ps. Not sure if this is the best approach for making multiple database connections, or if this is even right at all, so take it with a grain of salt.
Why do we have to pass sequelize & DataTypes ad parameter in Models. Can't we directly import from sequelize ? like const { DataTypes, Sequelize } = require('sequelize');
You could do it both ways! Passing it as a parameter is a standard for the sequelize-cli, but if your not using it than you probably should just import it!
Thank you i learn a lot can you make it with front end an todo task application so that others can deep dive learn using with node js express pug integration
I have a an example of how to make a todo list application on my 3 part series called: CRUD Tutorial ReactJS ! I don't use sequelize on that series, but transferring the normal mysql logic to sequelize is pretty straightforward!
Hi Pedro, how are you? I have a question, is this way of doing queries safe? Is this the frontend interfacing with the db directly? Im not sure about those things. Thank you!
Always great thanks !!
When I saw that you npm installed fs and path I realized you have no idea what you're talking about. These modules aren't packages. They are internal modules provided by nodejs itself. Thinking you need to install these demonstrates a great lack of experience with the platform.
You export your model function from User.js which is an anonymous function that takes 2 params - sequelize, DataTypes.
I don't understand how when you then import this function as db you don't have to pass an instance of sequelize and Datatypes to it?
How can you simply say db.sequelize.define (....) -- shouldn't you have to say db(sequelize, DataTypes).define ( ... ) ??
Hi very helpful video but i have an doubt could you pls help me to update the record using sequelize
Hi great video, need your help in one question.
I have two DBs in mysql. In DB1 we have person table and DB2 we have gender table.
I have to do association between DB1.person and DB2.gender.
can you help me with this.
How to retrieve the data use sequelize mysql when we insert execl data in database of three tables
what is the application you use to see your database and know whats inside it?
Thank You. Really helpful.
Glad it was helpful!
Bro, path and fs are native NodeJS modules.
Cannot read properties of undefined (reading 'findAll') what can I do!
Great tutorial, thanks! Any chance to get the GitHub repository to clone?
Hello Pedro, I wanted to use ES6 modules for importing, but can't figure out how to change the require imports to es6 inside models/index.js file
use "type" : "module" in your script file
I run into same error
I changed the .js files to ecma6, and it doesnt work. How can fix this issue?
sequelize: command not found
help me pro plssssss!!!
what should i use, pure SQL or Sequelize?
It depends on what is your application. However in a Job or an advanced project, usually you would use Sequelize. Its a lot more handy to use an ORM like Sequelize because then you don't need to write actual SQL. It is a way to convert SQL to normal JavaScript, so thats why almost every company uses it.
@@PedroTechnologies thank's .
hello, I got an error when I coding with your video.
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
^
TypeError: Class constructor model cannot be invoked without 'new'
Did you install 'path'? This error occurs in the file generated by the cli so that is weird hahaha I would try restarting the server!
Yes I installed it too. Now problem is okay. I figured it out
i had to use this command on bash "powershell Set-ExecutionPolicy RemoteSigned" on VS to skip the problem "cannot be loaded because running scripts is disabled on this system."
please upload about associations in sequelize
This should be an interesting video idea! I will make one!
@@PedroTechnologies awesome thanks
@@PedroTechnologies i really need the association because i am having problems with table relationships
I failed at step: sequelize init, return "sequelize : unrecognizable. previous step: npm install... seems ok with npm warning server@1.0.0 no description. help please
fix it with npx sequelize init help from previous comments,
thank you !@@jtcheng1805
thanks so much for this video!!!
Love this, thanks!
Why app. Get for inserting.. It should be app.post??
how can I read a database.sql file in node js?
I need to read this in my React js project using node
Anyone can help me?
What do you mean? You want to use an existing database or create a new one?
@@PedroTechnologies I want to use a existing database file. I need to read this database to get some data
great video! tysm
i think path and fs are inbuilt packages in nodejs so we dont need to install them
please zoom the screen or increase font size. ur screen is too big, does not mean that others have the same... if i watch it on mobile, the font is too small. barely reading
Why would you want to install fs when its built-in to nodejs
I wonder too, both path and fs are built-in to nodejs
where is next tutorial
This was a long time ago, but I should probably create a new series! Sorry about that!
How to update pls tell me brother
how to make SELECT * FROM posts join users on posts.UserId = users.id in sequelize.
Thank you a LOT!!!
Thank you brother
You don't need to install fs and path.... It's core modules!
The ORM dream. Just write SQL.
Nice bro 👌👌
I like your videos
🔥🔥🔥
thank you !!
Thank you.
Build once again project.