Это видео недоступно.
Сожалеем об этом.
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/
Hi, simply wanted to thank you for your videos.. watched the entire playlist. You have a great teaching style!
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.
awesome to hear that, good to know my videos are helping others!
@@WebDevJourney love from pakistan
Very nice explanation, I was struggling to understand how many-to-many worked, and now I get it :D
Keep up the good work! Would be nice to see some database designs on real world problems. Thanks for your videos!
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.
It took me 2 months to find a video like this 💯 Great Tutorial
Okay I know this is a loooong video. But hopefully you learned something because if not, well you need to watch the video again.
Excelent explanation!! very clear and easy to follow through!
Excelent comment!! very clear and easy to follow through!
Very useful mate! Thank you for this tutorial
thank you so much bro, you made it to easy to understand!❤
very well explained, thank you
Excelent tutorial, thanks man!
Thank you for existing
Very well explained!
Thank you so much sir!
You did great man, I understood well about the relations and special magic methods.
Awesome explanations thanks dude
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!
You save a life bro!!! Thank you.
A big thank you, bro.
Hey great tutorial! How could we do that but having the models in separated files? Sequelize throws an error
its really a great video...thanks alot
"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.
thank you sir, it helps me
Very resourceful
Thank you
What is the VSC extension you use to draw on screen? That's super cool!
its not an extension it's a software called epic pen and the best part is its free epic-pen.com/
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???
Nice video. I was wondering what extension you are using to draw on your screen?
its not an extension it's a software called epic pen and the best part is its free epic-pen.com/
@@WebDevJourney thank you so much
pls i have an issue,
how do i do the relatioship if all my models are in different files
You would need to export then import where needed then do the link.
Any link for the project code?
Anyone facing issue with hasMany association as its returning only return one record😕😕😕😕
thank you broo
Hey, is there a source code that i can possibly look at?
here you go github.com/webdevjourneyWDJ/postgres_sequelize
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
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
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?
trying to understand your question. You want to know how to create associations using the Sequelize-CLI?
@@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"
@@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
@@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.
@@MegaGian2009 then I will try to do a video on that when I have the time, Sorry that I can not do it faster
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
4:10 one to one
Tried to undo this 1 unlike by liking and subscribing
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"}})