Это видео недоступно.
Сожалеем об этом.

Postgres & Sequelize - Associations

Поделиться
HTML-код
  • Опубликовано: 7 авг 2024
  • Okay guys this is going to be a video solely on associations and implementing them.
    If you wish to support me, here is my patreon page:
    www.patreon.com/webdevjourney...
    If you wish to buy me some coffee:
    www.buymeacoffee.com/webdevjo...
    Model Associations: sequelize.org/master/manual/a...
    Docker Command to run Postgres: docker run --name postgres-dev -e POSTGRES_PASSWORD=admin -p 5432:5432 -d --rm postgres
    Get Docker IP Address:
    docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
    Server Boilerplate Github: github.com/webdevjourneyWDJ/S...
    Server Boilerplate Video: • How I Setup My Server
    Docker Postgres Image: hub.docker.com/_/postgres
    Postgres GUI: www.pgadmin.org/

Комментарии • 57

  • @albertohuerta
    @albertohuerta 2 года назад +1

    Hi, simply wanted to thank you for your videos.. watched the entire playlist. You have a great teaching style!

  • @pedrohw14
    @pedrohw14 3 года назад +16

    A big thank you, bro. I was getting crazy (believe you or not) for already more than 6 months trying to understand how this works and how to apply it. Finally I could create this association.

    • @WebDevJourney
      @WebDevJourney  3 года назад +4

      awesome to hear that, good to know my videos are helping others!

    • @hashirmughal5625
      @hashirmughal5625 Год назад

      @@WebDevJourney love from pakistan

  • @SinisterSpatula
    @SinisterSpatula 2 года назад

    Very nice explanation, I was struggling to understand how many-to-many worked, and now I get it :D

  • @curiousprogrammer90
    @curiousprogrammer90 3 года назад +1

    Keep up the good work! Would be nice to see some database designs on real world problems. Thanks for your videos!

  • @jetmartin9501
    @jetmartin9501 3 года назад +1

    Well done! It's a bit complicated...especially the Many-to-Many relationships but I think you did a good job. Thanks for taking the time to make this video. Cheers.

  • @nafihpp
    @nafihpp Год назад

    It took me 2 months to find a video like this 💯 Great Tutorial

  • @WebDevJourney
    @WebDevJourney  3 года назад +8

    Okay I know this is a loooong video. But hopefully you learned something because if not, well you need to watch the video again.

  • @juanpalacios593
    @juanpalacios593 2 года назад +1

    Excelent explanation!! very clear and easy to follow through!

    • @derppey
      @derppey 2 года назад +1

      Excelent comment!! very clear and easy to follow through!

  • @LePhenixGD
    @LePhenixGD 2 года назад

    Very useful mate! Thank you for this tutorial

  • @pawanpatel4338
    @pawanpatel4338 9 месяцев назад

    thank you so much bro, you made it to easy to understand!❤

  • @Onoffrei
    @Onoffrei 3 года назад +1

    very well explained, thank you

  • @adrianrobertoaguilarsandic6999
    @adrianrobertoaguilarsandic6999 2 года назад

    Excelent tutorial, thanks man!

  • @nouralsatari6424
    @nouralsatari6424 2 года назад

    Thank you for existing

  • @krithikashivaram1143
    @krithikashivaram1143 3 года назад

    Very well explained!

  • @shashankkr1008
    @shashankkr1008 9 месяцев назад

    Thank you so much sir!

  • @kavinbarath970
    @kavinbarath970 6 месяцев назад

    You did great man, I understood well about the relations and special magic methods.

  • @Ruhgtfo
    @Ruhgtfo 11 месяцев назад

    Awesome explanations thanks dude

  • @snyredbaron21
    @snyredbaron21 3 года назад +1

    Wow! Best explanation ever! You really do a great job!
    Btw, I love the part 39:01 "I don't have friends" XD I hope you were joking!

  • @asogbaibrahim9618
    @asogbaibrahim9618 Год назад

    You save a life bro!!! Thank you.

  • @mdivs
    @mdivs 2 года назад

    A big thank you, bro.

  • @germantellez2710
    @germantellez2710 2 года назад

    Hey great tutorial! How could we do that but having the models in separated files? Sequelize throws an error

  • @sandiprumbalama7086
    @sandiprumbalama7086 Год назад

    its really a great video...thanks alot

  • @j8ahmed
    @j8ahmed 3 года назад

    "Dude I hate when my printer just starts to update on it's own. It gives me the jumps."
    LOL that was so random but funny.

  • @louisv3800
    @louisv3800 2 года назад

    thank you sir, it helps me

  • @emmanueltoluwanimi8784
    @emmanueltoluwanimi8784 2 года назад

    Very resourceful

  • @rufaidajumaa2566
    @rufaidajumaa2566 3 года назад

    Thank you

  • @turingcs2001
    @turingcs2001 2 года назад

    What is the VSC extension you use to draw on screen? That's super cool!

    • @WebDevJourney
      @WebDevJourney  2 года назад +1

      its not an extension it's a software called epic pen and the best part is its free epic-pen.com/

  • @tanmaypaul4579
    @tanmaypaul4579 2 года назад

    i faced this issue : "createdUser.addRole is not a function", if i remove as: from the Role association option, then it works fine. what to do???

  • @xtgamezg
    @xtgamezg 2 года назад +1

    Nice video. I was wondering what extension you are using to draw on your screen?

    • @WebDevJourney
      @WebDevJourney  2 года назад +1

      its not an extension it's a software called epic pen and the best part is its free epic-pen.com/

    • @xtgamezg
      @xtgamezg 2 года назад

      @@WebDevJourney thank you so much

  • @user-ku9th2lh9m
    @user-ku9th2lh9m 10 месяцев назад

    pls i have an issue,
    how do i do the relatioship if all my models are in different files

    • @WebDevJourney
      @WebDevJourney  10 месяцев назад

      You would need to export then import where needed then do the link.

  • @user-jq3km8od6x
    @user-jq3km8od6x 6 месяцев назад

    Any link for the project code?

  • @blunderfoxbeta
    @blunderfoxbeta 2 года назад

    Anyone facing issue with hasMany association as its returning only return one record😕😕😕😕

  • @abdelilahbouhou5297
    @abdelilahbouhou5297 3 года назад

    thank you broo

  • @jahnathanexantus6098
    @jahnathanexantus6098 Год назад

    Hey, is there a source code that i can possibly look at?

    • @WebDevJourney
      @WebDevJourney  Год назад

      here you go github.com/webdevjourneyWDJ/postgres_sequelize

  • @faridzo1017
    @faridzo1017 2 года назад

    Thank you for this video :), how to do with 3 tables, users, posts, comments ? 1 user has multiple posts, 1 post has only one user, 1 post has multiple comments, 1 user has multiple comments, 1 comment has only one user

    • @faridzo1017
      @faridzo1017 2 года назад

      I found how to do it, in file user i add : User.belongsToMany(models.Post, { through: "Comments" }); and in file post i add : Post.belongsToMany(models.User, { through: "Comments" }) in folder migrations in file comment : i add that :
      userId: {
      type: Sequelize.INTEGER,
      references: {
      model:{
      tableName: "Users"
      },
      key: "id"
      },
      allowNull: false
      },
      postId: {
      type: Sequelize.INTEGER,
      references: {
      model:{
      tableName: "Posts"
      },
      key: "id"
      },
      allowNull: false

  • @MegaGian2009
    @MegaGian2009 3 года назад

    Hey men, im struggling a lot with a big API project that im developing. In this video, you use asociations between tables that are created by a const. Usign sequelize-CLI, every time that you create a new model, a new file is created and the asociations are declared in a static associate(models) {}. Its too dificult to explain doing associations by that method? Or maybe make a video about it?

    • @WebDevJourney
      @WebDevJourney  3 года назад

      trying to understand your question. You want to know how to create associations using the Sequelize-CLI?

    • @MegaGian2009
      @MegaGian2009 3 года назад

      @@WebDevJourney Yes, im sorry, my english isn't so good lol. I think you create the sequelize/models manually. When using Sequelize-CLI to create models, the associatios have a little different sintax.
      In my project, I have created the migrations files with the foreings keys associated columns and tables, but, when I wrote the associations in models file, things are quite different and having some errors of type "ForeignKeyConstraintError"

    • @WebDevJourney
      @WebDevJourney  3 года назад

      @@MegaGian2009 I found this levelup.gitconnected.com/creating-sequelize-associations-with-the-sequelize-cli-tool-d83caa902233
      Let me know if it helps if not ill try to make a video around this

    • @MegaGian2009
      @MegaGian2009 3 года назад

      @@WebDevJourney i think i already read that post, it was posted before sequelize v6 launch. So, the models creations are different. Using the same logic structure of a one-to-Many associations don't work using sequelize v6.

    • @WebDevJourney
      @WebDevJourney  3 года назад

      @@MegaGian2009 then I will try to do a video on that when I have the time, Sorry that I can not do it faster

  • @8koi245
    @8koi245 Год назад

    I did an easier version of the code, kind of makes aa dirty model loading but in the end it's cleaner... Anyway TYSM I got so lost in the explanation I was given :c

  • @standforlife1
    @standforlife1 2 года назад

    4:10 one to one

  • @danyalsaleem5883
    @danyalsaleem5883 2 года назад

    Tried to undo this 1 unlike by liking and subscribing

  • @m.iqbalmaulana7328
    @m.iqbalmaulana7328 2 года назад

    hmm I still dont get it in many-to-many relationship, why when user "wdj" followed "tom" the code say wdj.addUser(tom), isn't that should be wdj.addFollow(tom) ? assuming const wdj = user.findOne({where: {name: "wdj"}}) and const tom = user.findOne({where:{name: "tom"}})