Thursday, 13 April 2017

belongsTo vs hasMany in sequelize

Let say we have shirt table and jhon table.

in sequelize when we use db.jhon.hasMany(db.shirt) ,

then it create the foriegn key in the shirt table and we use db.shirt.belongsTo(db.jhon) , it create foriegn key of jhon in the shirt table.

So the taregt and source are just changing of foreign key . Is there are any more diffrence to diffrenciate these keywords hasMany and belongsTo

What it is ? why and when to use ??

Any help would appriciated !!

Thanks



via hardy

No comments:

Post a Comment