Learn Sequelize ORM on Node.js with MySQL From Scratch in One Video

Поділитися
Вставка
  • Опубліковано 29 вер 2024
  • Written Tutorial:
    go.ipenywis.com...
    💻 Github github.com/ipe...
    Our Udemy Courses:
    Let's Create A Nodejs Desktop Chat Application(React/Socket) :
    www.udemy.com/...
    -- Official Links---
    Official Website: ipenywis.com
    Official Facebook: go.ipenywis.com...
    Official Twitter: go.ipenywis.com...
    --Support US--
    By Becoming a Patreon: go.ipenywis.com...

КОМЕНТАРІ • 77

  • @lisangolachristian6676
    @lisangolachristian6676 5 років тому +13

    For all those who are getting error commands such as sequelize migration:generate ...,first of all install the package called 'sequelize-cli' by running `npm i sequelize-cli` or if you are using yarn,do `yarn add sequelize-cli`.After you can bootstrap by doing `npx sequelize-cli init` to have the folders model,migrations,config and seeders created for you.So,you can run either run the commande to generate a migration file or a model,or a commande to generate both a model and a migration file that you can customize.For that you can do :`npx sequelize-cli model:generate --name youmodelname --attributes att21:string,attr2:float` but you will name you model and your attributes according to your needs.To run migrations :`npx sequelize-cli db:migrate`.For more informations go to the official doc : docs.sequelizejs.com/manual/migrations.html

  • @Solodam
    @Solodam 4 роки тому +5

    You can completely skip the migration part, by creating the models as shown, but instead of creating migrate scripts, just import them and call .sync() method, and it will auto-create the table for you.
    its not the recommended way, but if you want something easy to follow, there you go :)

  • @note380
    @note380 5 років тому +4

    Great tutorial. You would show how to add the sequelize-hierachy plugin, I tried reading the docs but I am lost

  • @vinothkumar-xf4sx
    @vinothkumar-xf4sx 4 роки тому +8

    Great Tutorial for beginners. If you don't know anything about sequelize then this video gives you very good overview and hands on. Thank you so much for this video.

  • @rog0079
    @rog0079 3 роки тому +1

    Hi thanks for the video.
    Can you also make a video on how to setup mysql with mariaDb like you already did in this video, i cannot figure out the installation of mysql and mariab, i get error 'Access denied for user 'root'@'localhost' (using password: NO)'. It would be really helpful.
    Thanks in advance!

  • @overunityinventor
    @overunityinventor 4 роки тому +2

    It gave me a lot of confidence!

  • @r13aero
    @r13aero 4 роки тому

    very helpful sir thank you

  • @edspressomartini
    @edspressomartini 2 роки тому

    Around the 19 minutes mark, I had to run this instead: npx sequelize migration:generate --name create_tweets_table

  • @shivamsingh-mn3mf
    @shivamsingh-mn3mf 4 роки тому +1

    it's showing User.hasMany is not a function, can you help me?

  • @DanielA-zu5mt
    @DanielA-zu5mt 5 років тому

    ok it works like really good, but i wanted to be able to view my data in phpmyadmin also but i can't when i use postman everything works but for some reason i can't see it in phpmyadmin
    thanks

  • @fear9998
    @fear9998 3 роки тому

    The way you pronounce 'dialect' like 'delicate' is cute yet hilariously incorrect. :)

  • @physicsguybrian
    @physicsguybrian 4 роки тому +2

    First, thank you for this video!!! You are toggling between cap S and lower case s-equelize in const/other and that is really confusing. A long time ago on a planet far far away, I was taught that when using a sentence to define the meaning of a word, to never use the word itself or variants in the sentence. Define it using other words. You cause unnecessary confusion when you do things like const Sequelize = require("sequalize") and in another places you do....const sequelize = new Sequelize(stuff). I mean seriously, HOW does that make things clear? To me it does not. The context in each case ought to be explained and different names should be used to keep the context clear. Like const localSequelizeInstance = require("sequelize") would make learning this stuff far less confusing and assuming you are NOT teaching to folks who already know this stuff ('cause that would be pointless), then perhaps newbies, like me, could spend less time scratching our heads and more time absorbing you knowledge. I taught physics for almost 25 years and I can tell you, the first step to being a successful teacher is to realize that your first objective is to make sure your approach is not adding obstacles that obscure the process or add more confusion than students already have. I hope this is helpful. Kindest regards, Brian

    • @andrewboddyse
      @andrewboddyse 4 роки тому

      Brian, I think you are very generous giving such detailed feedback; I fully agree. I am coming from Oracle and deep knowledge of SQL. I find these ORMs horrible; I am looking for a solution to output JSON.

  • @anantgarg3436
    @anantgarg3436 4 роки тому +9

    So damn useful! Literally cleared all my doubts of working with ORM and Node.js. You explained it so beautifully and the tutorial provided is so well documented. Great work man.

  • @praff5308
    @praff5308 3 роки тому +5

    Great video but sure could do with some timestamps.

  • @BookOfSaints
    @BookOfSaints 5 років тому +5

    Can you set up the foreign key on the Tweet model when creating it instead of modifying the migration file?

  • @linocatucci
    @linocatucci 4 роки тому +4

    What do you need to do with migrations when you want to add an extra column to the user model later on in a live production system where you cannot drop the table?

    • @anderson129
      @anderson129 3 роки тому

      you can add another migration, to update a table that you want to add the extra column, search "queryInterface.addColumn"

  • @saimanish3385
    @saimanish3385 3 роки тому +1

    Hello.You are really doing a great job.Please do some stuff on making database level changes using sequelize when we are in already existing projects of production environment where there is need of altering tables.Because in most of the organisations the DBA people will be handling all the database related alter queries.If altered tables from their side, i have a doubt that do we need to change sequelize code in our repositories also?

  • @ayusharyal6346
    @ayusharyal6346 3 роки тому

    How to start mysql server in visual studio command prompt, unable to get sequelize command ...

  • @rebirthtobi
    @rebirthtobi 5 років тому +3

    since using global is bad, what other package or method can we use

    • @CoderOne
      @CoderOne  5 років тому

      Consider working with DI paradigm framework (Dependency Injection) like Nest.js which allows you to work with Singleton instance.

  • @sandipbiswas5460
    @sandipbiswas5460 4 роки тому

    " The package at "node_modules/sequelize/lib/sequelize.js" attempted to import the Node standard library module "url". It failed because React Native does not include the Node standard library"
    getting this error when I'm trying to use Sequelize in React-native app.
    What changes should I make?

  • @mohamedyoussef8835
    @mohamedyoussef8835 Рік тому

    Awesome video ++++++++++++ 🙂

  • @ishjotsingh9373
    @ishjotsingh9373 4 роки тому

    I am getting the following error while using "sequelize db: migrate"
    The "url" argument must be of type string. Received type object
    Anyone knows how to fix this?

  • @programmingwithnit5308
    @programmingwithnit5308 Рік тому

    Thanks

  • @christianangelomsulit3759
    @christianangelomsulit3759 4 роки тому

    Will hasMany and belongsTo modify the table after it's execution to create a relationship?

  • @hemantpargain7193
    @hemantpargain7193 3 роки тому

    you can create model schema of tables through sequelize cli .

  • @burakcekic6609
    @burakcekic6609 3 роки тому

    I've been working for inner join in sequelize for two days. I solved it thanks to you

  • @enohvisor9832
    @enohvisor9832 5 років тому +2

    All good. But the monotony of the voice makes me sleepy

    • @physicsguybrian
      @physicsguybrian 4 роки тому

      You probably need more sleep ;-)

    • @tkssharma
      @tkssharma 4 роки тому

      ua-cam.com/video/MnljgIYwiaI/v-deo.html

  • @manee427
    @manee427 Рік тому

    perfect

  • @przemekbaj7978
    @przemekbaj7978 3 роки тому

    Is there any way to make migrations automatically like in Django?

  • @brunofunnie
    @brunofunnie 4 роки тому

    It's a great tutorial IF you want to see it working. But for a project you basically removed one of the best scenarios of folder organization that is the one that "sequelize init" create for you and used a "single file" format what is awful even for micro projects... still a good video to "see it working" nothing more than that.

    • @tkssharma
      @tkssharma 4 роки тому

      ua-cam.com/video/MnljgIYwiaI/v-deo.html

  • @Seb_a.__cb
    @Seb_a.__cb 3 роки тому

    thanks for making this video, it still holds up to this day and it makes sequelize really clear!

  • @differentfun9797
    @differentfun9797 2 роки тому

    definitely, this video is really helpful.

  • @angelmartinez5820
    @angelmartinez5820 4 роки тому

    ¿How can connect to real db? change the host for example@example.com?

  • @ashishsrivastav8201
    @ashishsrivastav8201 4 роки тому +1

    Really good explanation. You actually got my interest in sequelize.

  • @sobhanm9576
    @sobhanm9576 3 роки тому

    keep up my friend, u are freakin good at what u do

  • @MiltonIsaya
    @MiltonIsaya 3 роки тому

    Great video. It is very informative.Thank you

  • @shreyakamoji2508
    @shreyakamoji2508 4 роки тому

    Can you please share the source code of this??

  • @yesminameddeb8412
    @yesminameddeb8412 3 роки тому

    really got my interest, how clear the explanation was! thank you a lot.
    is it possible to make a video about inheritance using sequelize, thanks again.

    • @CoderOne
      @CoderOne  3 роки тому

      Glad you liked it. Great suggestion!

  • @ameedfaridi2739
    @ameedfaridi2739 3 роки тому

    how can I use it with APIs?

  • @ellsonmendesYT
    @ellsonmendesYT 3 роки тому

    gr8t tutorial dude!

  • @kcchiefsfan3752
    @kcchiefsfan3752 3 роки тому

    Great video, thanks!

  • @yuomtheara
    @yuomtheara 5 років тому

    don't get raw result [object] of `.findAll()`

  • @muddassirhussain9598
    @muddassirhussain9598 5 років тому

    Hi,
    I am having following error while running migration command ($ sequelize db:migrate), can you help me fix it
    ERROR: Client does not support authentication protocol requested by server; c server; consider upgrading MySQL client

    • @jonasgrnbek7113
      @jonasgrnbek7113 5 років тому

      have you upgraded your mysql client?

    • @hanweijie8092
      @hanweijie8092 5 років тому

      I think you need to place the same configuration parameters such as (localhost, database, username, password) from connection.js to config.json file.
      [This approach resolve the issue:]
      Example:
      ----------------------
      | Config.json |
      ---------------------
      {
      "development": {
      "username": "root",
      "password": "abcdef",
      "database": "blahblah",
      "host": "127.0.0.1",
      "dialect": "mysql",
      "port": 8888, /* phpmyadmin port */
      "dialectOptions": {
      "socketPath": "/Applications/MAMP/tmp/mysql/mysql.sock" /* for linux or mac using mamp */
      }
      }
      --------------------------
      | Connection.js |
      --------------------------
      const Sequelize = require('sequelize');
      const sequelize = new Sequelize('blahblah', 'root', 'abcdef', {
      host: 'localhost',
      dialect: 'mysql',
      port: 8888, /* phpmyadmin port */
      logging: function () {},
      pool: {
      max: 5,
      min: 0,
      acquire: 30000,
      idle: 10000
      },
      dialectOptions: {
      socketPath: '/Applications/MAMP/tmp/mysql/mysql.sock' /* for linux or mac using mamp */
      },
      define: {
      paranoid: true
      }
      });
      sequelize.authenticate().then(() => {
      module.exports = sequelize;
      global.sequelize = sequelize;
      console.log('MYSQL connection was established successfully.');
      }).catch(error => {
      console.error('Unable to connect to the MYSQL Server: ', error);
      }).finally(() => {
      sequelize.close();
      });

  • @WilcoGroothand
    @WilcoGroothand 2 роки тому

    Great to the point. Thx

  • @mohammadfaisal9586
    @mohammadfaisal9586 3 роки тому

    nice explaination.... appreciate it

  • @buneriblogger
    @buneriblogger 4 роки тому

    Importing models from database
    -- sequelize-automate can help you with ;)

    • @tkssharma
      @tkssharma 4 роки тому

      ua-cam.com/video/MnljgIYwiaI/v-deo.html

  • @hemantpargain7193
    @hemantpargain7193 3 роки тому

    outdated

  • @jamaScript
    @jamaScript 3 роки тому

    Super helpful and crystal clear 👍🏽

  • @khalidkhan5308
    @khalidkhan5308 4 роки тому

    RIP accent

  • @Sndiso
    @Sndiso 4 роки тому

    Source code please

  • @aasali40
    @aasali40 4 роки тому

    I keep getting User.create is not a function !!!

    • @aasali40
      @aasali40 4 роки тому

      [ FIXED ] 2020 UPDATE : the newly generated models can bring you the error of " Error : User.create is not a function "
      change the models the same as the ones this guy made,
      Thanks bro

  • @solomonmeresa3782
    @solomonmeresa3782 4 роки тому

    Nice one!

  • @dawid_dahl
    @dawid_dahl 4 роки тому

    Thank you.

  • @caseyspires1265
    @caseyspires1265 5 років тому

    Why does sequelize fail to load the Typings in my project even when i directly specify in my json.config.

    • @CoderOne
      @CoderOne  5 років тому

      Try to install @types/sequelize

  • @compteprivefr
    @compteprivefr 5 років тому

    Nice, will this work if I use postgres? Are there any syntax differences?

    • @CoderOne
      @CoderOne  5 років тому +3

      Yes I will work with postgres without changing a line of code all you need to change is the driver dialect to postgres and your database connection settings.

  • @sdfsdsdfds8655
    @sdfsdsdfds8655 5 років тому

    how to create tree folder ?

  • @yashpatil2074
    @yashpatil2074 5 років тому

    Thank You.

  • @natqe4049
    @natqe4049 5 років тому

    thanks!!!