I'm confronting on a problem since few exhausting hours on linking two models with Sequelize.
var Ticket = sequelize.define("Ticket", {
IDTicketBase: { type:DataTypes.INTEGER, primaryKey: true },
IDStatus: DataTypes.INTEGER,
}
associate: function(models){
models.Ticket.hasOne(models.Status, {foreignKey: 'IDStatus'} );
}
var Status = sequelize.define("Status", {
IDStatus : { type:DataTypes.INTEGER, primaryKey: true },
Name: DataTypes.STRING
}
associate: function(models){
models.Status.belongsTo(models.Ticket, {foreignKey: 'IDStatus'} );
}
This code produces the relation Ticket.IDTicketBase = Status.IDStatus. What I have to write on my two models if I want the relation Ticket.IDStatus= Status.IDStatus ?
I want to produce on 1 to 1 association.
Thanks for the responses ;)
via Bloche Valentin
No comments:
Post a Comment