No video

How to Use Sequelize ORM in NodeJS - Tutorial

  Рет қаралды 115,260

PedroTech

PedroTech

Күн бұрын

Checkout my discord for any questions: / discord
-
Hi guys, in this video I teach you guys how to use a SQL ORM called Sequelize. This will allow you guys to handle database queries using an object structure.
-
Please leave a comment on what topic you guys want me to cover next!
SUBSCRIBE!
Social
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Website: machadopedro.com
Twitter: / machadop1407
Instagram: / _pedro.machado_
Github: github.com/mac...
Email: machadop1407@gmail.com

Пікірлер: 110
@joshuahamann2075
@joshuahamann2075 Жыл бұрын
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.
@vieiratn
@vieiratn 3 жыл бұрын
The difference between mysql and mysql2 is basically promises. The package mysql2 allows you to work with asynchronous JS. Thanks for the video bro.
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Thanks for sharing! I actually never realized this. This can be helpful cause ive been caught in callback 'hell' situations using mysql.
@markokafor7432
@markokafor7432 3 жыл бұрын
You didn’t need to install path and fs. They are built in node js modules
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Yes
@angelbythewings
@angelbythewings 3 жыл бұрын
@@PedroTechnologies Also its not require, its request and response 😄
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
@@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
@angelbythewings 3 жыл бұрын
@@PedroTechnologies that's completely understandable. Sorry if you already knew, I shouldn't have pointed out. BTW it was a very nice tutorial
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
@@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
@lucylu184
@lucylu184 3 жыл бұрын
Your videos helped me get an internship. I'm really grateful.
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Wow thats amazingg! If you don't mind, where you going to work? This makes me very happy!
@cooperathletics6278
@cooperathletics6278 3 жыл бұрын
Concise and straight to the point! Beats these 3 hour crash course vids. Thanks for the tutorial.
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Thank you! Really appreciate it!
@tekhaven
@tekhaven 3 жыл бұрын
@@PedroTechnologies Awesome tutorial and very straight to the point
@CourageousCreatives
@CourageousCreatives 3 жыл бұрын
Another really great run-down on a topic! Thanks!
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Glad you enjoyed it!
@parasarora5869
@parasarora5869 3 жыл бұрын
Amazing tutorial sir!!... you cleared my doubts regarding sequelize in one go 👍👍
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Glad to hear that
@Porrruh
@Porrruh 3 жыл бұрын
Pedro the way you explained it clicked really well thank you keep up the good work. Will look for more posts :-)
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
That makes me happy! Thank you so much!
@aksaurooj838
@aksaurooj838 3 жыл бұрын
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
@fredrickemmanuel479
@fredrickemmanuel479 20 күн бұрын
am also getting same error
@blakebard
@blakebard 12 күн бұрын
npm install -g sequelize-cli
@uktech9432
@uktech9432 Ай бұрын
Honestly it was very well explained ❤.
@triptisingla4897
@triptisingla4897 11 ай бұрын
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
@anonlegion9096
@anonlegion9096 Жыл бұрын
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
@tekhaven
@tekhaven 3 жыл бұрын
Please can you do a tutorial on Table relationship? Really need that with sequelize
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Some people requested this, I plan on doing it!
@xxfrizzzerxx6890
@xxfrizzzerxx6890 3 жыл бұрын
Need it !
@waynefaustorilla
@waynefaustorilla 3 жыл бұрын
Yes please
@MrChilo89
@MrChilo89 2 жыл бұрын
yes please
@unsolvedstories1016
@unsolvedstories1016 Жыл бұрын
Beautiful and most required video 🙏
@ibrahimacanada
@ibrahimacanada 2 жыл бұрын
Always great thanks !!
@gokulkurup1584
@gokulkurup1584 3 жыл бұрын
Really Helpful. Thanks for the great tutorial !
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Glad it was helpful!
@Cynthia-cw6kd
@Cynthia-cw6kd 17 күн бұрын
Love this, thanks!
@k303k
@k303k 10 ай бұрын
Thanks for the video Pedro!
@danielkibby6601
@danielkibby6601 11 ай бұрын
This is great, so I glad I found your video :D
@austin96tig
@austin96tig 3 жыл бұрын
That was a really good explanation!
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Glad you liked it!
@TolaFoundationMw
@TolaFoundationMw 9 ай бұрын
🔥🔥🔥
@user-jr5ky9lv6g
@user-jr5ky9lv6g 8 ай бұрын
You can also use Postman to test different methods like post without frontend at all 14:40
@jabezraja9383
@jabezraja9383 3 жыл бұрын
i really appreciate your effort... it was very usefull for me
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Glad it was helpful!
@ianpropst-campbell6028
@ianpropst-campbell6028 Жыл бұрын
Thank you for this helpful tutorial!
@Spmdiamond
@Spmdiamond 2 жыл бұрын
Love you bro thanks a lot it is best way to learn for beginners
@Pareshbpatel
@Pareshbpatel Жыл бұрын
An excellent introduction to using Sequilize to perform CRUD Operations on a mySQL database. Thanks, Pedro {2023-06-05}
@stonecomstock
@stonecomstock 2 жыл бұрын
this was very helpful! thank you
@user-hb6vu3xu9c
@user-hb6vu3xu9c Жыл бұрын
thank you sir, useful and easy to understand
@shivarammuthukumaraswamy7164
@shivarammuthukumaraswamy7164 3 жыл бұрын
Thank You. Really helpful.
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Glad it was helpful!
@thesinged196
@thesinged196 2 жыл бұрын
sequelize: command not found help me pro plssssss!!!
@Vir7uaLGameplays
@Vir7uaLGameplays Жыл бұрын
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.
@hyphenbruh7376
@hyphenbruh7376 Жыл бұрын
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.
@josesoltero6057
@josesoltero6057 Жыл бұрын
thanks so much for this video!!!
@aadarshaacharya267
@aadarshaacharya267 3 жыл бұрын
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');
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
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!
@MarsTheProgrammer
@MarsTheProgrammer 3 жыл бұрын
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.
@MarsTheProgrammer
@MarsTheProgrammer 3 жыл бұрын
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");
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
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!
@PanlasangMotour
@PanlasangMotour 3 жыл бұрын
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
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
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!
@fedeabj
@fedeabj 2 жыл бұрын
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!
@tigranavagyan5922
@tigranavagyan5922 2 жыл бұрын
Thank you a LOT!!!
@earlgrey8611
@earlgrey8611 8 ай бұрын
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 ( ... ) ??
@programmingwithnit5308
@programmingwithnit5308 Жыл бұрын
Thank you brother
@maelstrom57
@maelstrom57 Ай бұрын
Bro, path and fs are native NodeJS modules.
@Omkara2664
@Omkara2664 Жыл бұрын
Nice bro 👌👌
@lg-25
@lg-25 Ай бұрын
How to retrieve the data use sequelize mysql when we insert execl data in database of three tables
@xbzq
@xbzq Жыл бұрын
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.
@yonatanshalev9428
@yonatanshalev9428 Жыл бұрын
Great tutorial, thanks! Any chance to get the GitHub repository to clone?
@DeveenRathnayake
@DeveenRathnayake 3 жыл бұрын
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'
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
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!
@DeveenRathnayake
@DeveenRathnayake 3 жыл бұрын
Yes I installed it too. Now problem is okay. I figured it out
@kishorep3376
@kishorep3376 Жыл бұрын
Cannot read properties of undefined (reading 'findAll') what can I do!
@mr.hassaan7785
@mr.hassaan7785 3 жыл бұрын
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
@7gsReef
@7gsReef Жыл бұрын
what is the application you use to see your database and know whats inside it?
@theverybestdev
@theverybestdev 3 жыл бұрын
please upload about associations in sequelize
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
This should be an interesting video idea! I will make one!
@theverybestdev
@theverybestdev 3 жыл бұрын
@@PedroTechnologies awesome thanks
@tekhaven
@tekhaven 3 жыл бұрын
@@PedroTechnologies i really need the association because i am having problems with table relationships
@davidanwar6996
@davidanwar6996 3 жыл бұрын
what should i use, pure SQL or Sequelize?
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
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.
@davidanwar6996
@davidanwar6996 3 жыл бұрын
@@PedroTechnologies thank's .
@premalatha5182
@premalatha5182 3 жыл бұрын
Hi very helpful video but i have an doubt could you pls help me to update the record using sequelize
@navinwadhwa595
@navinwadhwa595 6 ай бұрын
Why app. Get for inserting.. It should be app.post??
@HHHanant
@HHHanant 6 ай бұрын
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.
@MrChilo89
@MrChilo89 2 жыл бұрын
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."
@saladin_advanced
@saladin_advanced 2 жыл бұрын
Thank you.
@QuickTuts
@QuickTuts Жыл бұрын
Isn't fs and path built-in Nodejs? Why are you installing them?
@aakarshanthapa889
@aakarshanthapa889 2 жыл бұрын
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
@govinda399
@govinda399 Жыл бұрын
use "type" : "module" in your script file
@sang4005
@sang4005 4 ай бұрын
I run into same error
@sridharkatta3461
@sridharkatta3461 3 жыл бұрын
i think path and fs are inbuilt packages in nodejs so we dont need to install them
@jtcheng1805
@jtcheng1805 3 жыл бұрын
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
@jtcheng1805
@jtcheng1805 3 жыл бұрын
fix it with npx sequelize init help from previous comments,
@hichamamroussi9087
@hichamamroussi9087 9 ай бұрын
thank you !@@jtcheng1805
@nathansantos4197
@nathansantos4197 3 жыл бұрын
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?
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
What do you mean? You want to use an existing database or create a new one?
@nathansantos4197
@nathansantos4197 3 жыл бұрын
@@PedroTechnologies I want to use a existing database file. I need to read this database to get some data
@alexdev5734
@alexdev5734 6 ай бұрын
Why would you want to install fs when its built-in to nodejs
@sang4005
@sang4005 4 ай бұрын
I wonder too, both path and fs are built-in to nodejs
@instant-code
@instant-code 3 жыл бұрын
where is next tutorial
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
This was a long time ago, but I should probably create a new series! Sorry about that!
@matthewclarke1926
@matthewclarke1926 Жыл бұрын
The ORM dream. Just write SQL.
@ibrahimmainge
@ibrahimmainge Жыл бұрын
You don't need to install fs and path.... It's core modules!
@kishore2398
@kishore2398 2 жыл бұрын
How to update pls tell me brother
@note_to_you
@note_to_you 2 жыл бұрын
how to make SELECT * FROM posts join users on posts.UserId = users.id in sequelize.
@pankajsuryavanshi8332
@pankajsuryavanshi8332 Жыл бұрын
Build once again project.
Node.js и MySQL через ORM. Применяем Sequelize для запросов в базу данных
30:24
WebDev с нуля. Канал Алекса Лущенко
Рет қаралды 8 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 404 М.
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 20 МЛН
Kind Waiter's Gesture to Homeless Boy #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 11 МЛН
КАКУЮ ДВЕРЬ ВЫБРАТЬ? 😂 #Shorts
00:45
НУБАСТЕР
Рет қаралды 3 МЛН
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 108 МЛН
Learn Express Middleware In 14 Minutes
14:48
Web Dev Simplified
Рет қаралды 394 М.
Sequelize ORM Tutorial (all in one video)
49:59
Classsed
Рет қаралды 161 М.
Learn Sequelize - A NodeJS ORM | The Best Way to Write Database Queries
22:03
Kritika & Pranav | Programmer Couple
Рет қаралды 84 М.
Node and Express - Connect to MySQL Database with Sequelize
22:55
How to Setup MySQL in NodeJS / Express - Tutorial
14:33
PedroTech
Рет қаралды 15 М.
Postgres & Sequelize - Associations
48:58
Web Dev Journey
Рет қаралды 43 М.
Build a Node.js App With Sequelize [1] - Connection & Model
24:07
Traversy Media
Рет қаралды 283 М.
Learn JWT in 10 Minutes with Express, Node, and Cookie Parser
10:20
Web Dev Cody
Рет қаралды 106 М.
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 20 МЛН