How to Use Sequelize ORM in NodeJS - Tutorial

  Рет қаралды 122,783

PedroTech

PedroTech

Күн бұрын

Пікірлер: 115
@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.
@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!
@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
@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
@triptisingla4897
@triptisingla4897 Жыл бұрын
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
@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.
@parasarora5869
@parasarora5869 3 жыл бұрын
Amazing tutorial sir!!... you cleared my doubts regarding sequelize in one go 👍👍
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Glad to hear that
@CourageousCreatives
@CourageousCreatives 3 жыл бұрын
Another really great run-down on a topic! Thanks!
@PedroTechnologies
@PedroTechnologies 3 жыл бұрын
Glad you enjoyed it!
@uktech9432
@uktech9432 4 ай бұрын
Honestly it was very well explained ❤.
@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 🙏
@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 3 ай бұрын
am also getting same error
@blakebard
@blakebard 3 ай бұрын
npm install -g sequelize-cli
@alberto5056
@alberto5056 Ай бұрын
I have the same error, you have to use "npx sequelize-cli init"
@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}
@СтепаСорокин-е2я
@СтепаСорокин-е2я 11 ай бұрын
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!
@danielkibby6601
@danielkibby6601 Жыл бұрын
This is great, so I glad I found your video :D
@gokulkurup1584
@gokulkurup1584 4 жыл бұрын
Really Helpful. Thanks for the great tutorial !
@PedroTechnologies
@PedroTechnologies 4 жыл бұрын
Glad it was helpful!
@MarsTheProgrammer
@MarsTheProgrammer 4 жыл бұрын
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 4 жыл бұрын
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 4 жыл бұрын
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!
@ianpropst-campbell6028
@ianpropst-campbell6028 Жыл бұрын
Thank you for this helpful tutorial!
@Мертвыйотчим
@Мертвыйотчим Жыл бұрын
thank you sir, useful and easy to understand
@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!
@austin96tig
@austin96tig 4 жыл бұрын
That was a really good explanation!
@PedroTechnologies
@PedroTechnologies 4 жыл бұрын
Glad you liked it!
@Vir7uaLGameplays
@Vir7uaLGameplays 2 жыл бұрын
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.
@k303k
@k303k Жыл бұрын
Thanks for the video Pedro!
@7gsReef
@7gsReef Жыл бұрын
what is the application you use to see your database and know whats inside it?
@stonecomstock
@stonecomstock 2 жыл бұрын
this was very helpful! thank you
@thesinged196
@thesinged196 2 жыл бұрын
sequelize: command not found help me pro plssssss!!!
@yonatanshalev9428
@yonatanshalev9428 Жыл бұрын
Great tutorial, thanks! Any chance to get the GitHub repository to clone?
@earlgrey8611
@earlgrey8611 11 ай бұрын
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 ( ... ) ??
@PanlasangMotour
@PanlasangMotour 4 жыл бұрын
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 4 жыл бұрын
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!
@ibrahimacanada
@ibrahimacanada 2 жыл бұрын
Always great thanks !!
@HHHanant
@HHHanant 9 ай бұрын
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.
@BrawlStars-kq9mt
@BrawlStars-kq9mt 2 ай бұрын
I changed the .js files to ecma6, and it doesnt work. How can fix this issue?
@SmokyBigSmoke
@SmokyBigSmoke 4 жыл бұрын
Thank You. Really helpful.
@PedroTechnologies
@PedroTechnologies 4 жыл бұрын
Glad it was helpful!
@lg-25
@lg-25 4 ай бұрын
How to retrieve the data use sequelize mysql when we insert execl data in database of three tables
@Cynthia-cw6kd
@Cynthia-cw6kd 3 ай бұрын
Love this, thanks!
@davidanwar6996
@davidanwar6996 4 жыл бұрын
what should i use, pure SQL or Sequelize?
@PedroTechnologies
@PedroTechnologies 4 жыл бұрын
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 4 жыл бұрын
@@PedroTechnologies thank's .
@josesoltero6057
@josesoltero6057 Жыл бұрын
thanks so much for this video!!!
@maelstrom57
@maelstrom57 4 ай бұрын
Bro, path and fs are native NodeJS modules.
@premalatha5182
@premalatha5182 3 жыл бұрын
Hi very helpful video but i have an doubt could you pls help me to update the record using sequelize
@kishorep3376
@kishorep3376 2 жыл бұрын
Cannot read properties of undefined (reading 'findAll') what can I do!
@aadarshaacharya267
@aadarshaacharya267 4 жыл бұрын
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 4 жыл бұрын
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!
@reni2090
@reni2090 11 күн бұрын
great video! tysm
@DeveenRathnayake
@DeveenRathnayake 4 жыл бұрын
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 4 жыл бұрын
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 4 жыл бұрын
Yes I installed it too. Now problem is okay. I figured it out
@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
@programmingwithnit5308
@programmingwithnit5308 Жыл бұрын
Thank you brother
@navinwadhwa595
@navinwadhwa595 9 ай бұрын
Why app. Get for inserting.. It should be app.post??
@aakarshanthapa889
@aakarshanthapa889 3 жыл бұрын
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 2 жыл бұрын
use "type" : "module" in your script file
@sang4005
@sang4005 6 ай бұрын
I run into same error
@theverybestdev
@theverybestdev 4 жыл бұрын
please upload about associations in sequelize
@PedroTechnologies
@PedroTechnologies 4 жыл бұрын
This should be an interesting video idea! I will make one!
@theverybestdev
@theverybestdev 4 жыл бұрын
@@PedroTechnologies awesome thanks
@tekhaven
@tekhaven 3 жыл бұрын
@@PedroTechnologies i really need the association because i am having problems with table relationships
@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."
@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 Жыл бұрын
thank you !@@jtcheng1805
@נתנאלנגוסה-ס3ס
@נתנאלנגוסה-ס3ס 2 ай бұрын
thank you !!
@sridharkatta3461
@sridharkatta3461 3 жыл бұрын
i think path and fs are inbuilt packages in nodejs so we dont need to install them
@alexdev5734
@alexdev5734 9 ай бұрын
Why would you want to install fs when its built-in to nodejs
@sang4005
@sang4005 6 ай бұрын
I wonder too, both path and fs are built-in to nodejs
@tigranavagyan5922
@tigranavagyan5922 2 жыл бұрын
Thank you a LOT!!!
@matthewclarke1926
@matthewclarke1926 Жыл бұрын
The ORM dream. Just write SQL.
@Jeancympoycoding
@Jeancympoycoding 2 ай бұрын
I like your videos
@TolaFoundationMw
@TolaFoundationMw Жыл бұрын
🔥🔥🔥
@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
@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
@instant-code
@instant-code 4 жыл бұрын
where is next tutorial
@PedroTechnologies
@PedroTechnologies 4 жыл бұрын
This was a long time ago, but I should probably create a new series! Sorry about that!
@saladin_advanced
@saladin_advanced 2 жыл бұрын
Thank you.
@note_to_you
@note_to_you 3 жыл бұрын
how to make SELECT * FROM posts join users on posts.UserId = users.id in sequelize.
@Omkara2664
@Omkara2664 Жыл бұрын
Nice bro 👌👌
@pankajsuryavanshi8332
@pankajsuryavanshi8332 Жыл бұрын
Build once again project.
Sequelize ORM Tutorial (all in one video)
49:59
Classsed
Рет қаралды 164 М.
Learn Sequelize - A NodeJS ORM | The Best Way to Write Database Queries
22:03
Kritika & Pranav | Programmer Couple
Рет қаралды 86 М.
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 136 МЛН
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 17 МЛН
ЛУЧШИЙ ФОКУС + секрет! #shorts
00:12
Роман Magic
Рет қаралды 35 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 2,1 МЛН
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 435 М.
How to Setup MySQL in NodeJS / Express - Tutorial
14:33
PedroTech
Рет қаралды 16 М.
Node.js и MySQL через ORM. Применяем Sequelize для запросов в базу данных
30:24
WebDev с нуля. Канал Алекса Лущенко
Рет қаралды 8 М.
Prisma Vs. TypeORM Vs. Sequelize | Which is Better?
12:44
PedroTech
Рет қаралды 34 М.
Node.js Project Structure and Architecture Best Practices
7:38
Software Developer Diaries
Рет қаралды 38 М.
I Have A New Favorite Database Tool
5:46
Theo - t3․gg
Рет қаралды 122 М.
Learn Express Middleware In 14 Minutes
14:48
Web Dev Simplified
Рет қаралды 405 М.
Mastering Sequelize Migrations: A Basic Example
9:00
Alex Rusin
Рет қаралды 10 М.
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 136 МЛН