hooks como foreignkey

This commit is contained in:
2020-10-01 10:14:38 -05:00
parent 886ec20eaa
commit 0df256dcac
10 changed files with 126 additions and 160 deletions
+8 -8
View File
@@ -20,14 +20,6 @@ Carrito.init(
type: DataTypes.STRING(1),
allowNull: false,
},
idTipoCarrito: {
type: DataTypes.INTEGER,
references: {
model: TipoCarrito,
key: 'idTipoCarrito',
},
allowNull: false,
},
},
{
sequelize,
@@ -36,4 +28,12 @@ Carrito.init(
}
)
Carrito.belongsTo(TipoCarrito, {
foreignKey: {
name: 'idTipoCarrito',
type: DataTypes.INTEGER,
allowNull: false,
},
})
module.exports = Carrito