hooks como foreignkey
This commit is contained in:
@@ -13,22 +13,6 @@ CarreraPlantel.init(
|
|||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
unique: true,
|
unique: true,
|
||||||
},
|
},
|
||||||
idPlantel: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Plantel,
|
|
||||||
key: 'idPlantel',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
idCarrera: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Carrera,
|
|
||||||
key: 'idCarrera',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequelize,
|
sequelize,
|
||||||
@@ -38,7 +22,12 @@ CarreraPlantel.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
CarreraPlantel.belongsTo(Carrera, { foreignKey: 'idCarrera' })
|
CarreraPlantel.belongsTo(Carrera, {
|
||||||
CarreraPlantel.belongsTo(Plantel, { foreignKey: 'idPlantel' })
|
foreignKey: { type: DataTypes.INTEGER, name: 'idCarrera', allowNull: false },
|
||||||
|
})
|
||||||
|
|
||||||
|
CarreraPlantel.belongsTo(Plantel, {
|
||||||
|
foreignKey: { type: DataTypes.INTEGER, name: 'idPlantel', allowNull: false },
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = CarreraPlantel
|
module.exports = CarreraPlantel
|
||||||
|
|||||||
@@ -20,14 +20,6 @@ Carrito.init(
|
|||||||
type: DataTypes.STRING(1),
|
type: DataTypes.STRING(1),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
idTipoCarrito: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: TipoCarrito,
|
|
||||||
key: 'idTipoCarrito',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequelize,
|
sequelize,
|
||||||
@@ -36,4 +28,12 @@ Carrito.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Carrito.belongsTo(TipoCarrito, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idTipoCarrito',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = Carrito
|
module.exports = Carrito
|
||||||
|
|||||||
+17
-16
@@ -28,24 +28,8 @@ Equipo.init(
|
|||||||
activo: {
|
activo: {
|
||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
|
||||||
idCarrito: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Carrito,
|
|
||||||
key: 'idCarrito',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
idStatus: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Status,
|
|
||||||
key: 'idStatus',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
// defaultValue: 1,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequelize,
|
sequelize,
|
||||||
@@ -54,4 +38,21 @@ Equipo.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Equipo.belongsTo(Status, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idStatus',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 1,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
Equipo.belongsTo(Carrito, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idCarrito',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = Equipo
|
module.exports = Equipo
|
||||||
|
|||||||
@@ -19,15 +19,7 @@ Mesa.init(
|
|||||||
activo: {
|
activo: {
|
||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
|
||||||
idStatus: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Status,
|
|
||||||
key: 'idStatus',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: 1,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -37,4 +29,13 @@ Mesa.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Mesa.belongsTo(Status, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idStatus',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 1,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = Mesa
|
module.exports = Mesa
|
||||||
|
|||||||
+12
-16
@@ -21,22 +21,6 @@ Multa.init(
|
|||||||
type: DataTypes.STRING(100),
|
type: DataTypes.STRING(100),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
idTipoMulta: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: TipoMulta,
|
|
||||||
key: 'idTipoMulta',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
idPrestamo: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Prestamo,
|
|
||||||
key: 'idPrestamo',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequelize,
|
sequelize,
|
||||||
@@ -45,4 +29,16 @@ Multa.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Multa.belongsTo(TipoMulta, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idTipoMulta',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
Multa.belongsTo(Prestamo, {
|
||||||
|
foreignKey: { name: 'idPrestamo', type: DataTypes.INTEGER, allowNull: false },
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = Multa
|
module.exports = Multa
|
||||||
|
|||||||
@@ -20,14 +20,6 @@ Operador.init(
|
|||||||
type: DataTypes.STRING(100),
|
type: DataTypes.STRING(100),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
idTipoOperador: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: TipoOperador,
|
|
||||||
key: 'idTipoOperador',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequelize,
|
sequelize,
|
||||||
@@ -36,4 +28,12 @@ Operador.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Operador.belongsTo(TipoOperador, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idTipoOperador',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = Operador
|
module.exports = Operador
|
||||||
|
|||||||
+36
-55
@@ -28,63 +28,8 @@ Prestamo.init(
|
|||||||
activo: {
|
activo: {
|
||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
},
|
|
||||||
idUsuario: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Usuario,
|
|
||||||
key: 'idUsuario',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
idOperadorEntrega: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Operador,
|
|
||||||
key: 'idOperador',
|
|
||||||
},
|
|
||||||
allowNull: true,
|
|
||||||
},
|
|
||||||
idOperadorRegreso: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Operador,
|
|
||||||
key: 'idOperador',
|
|
||||||
},
|
|
||||||
allowNull: true,
|
|
||||||
},
|
|
||||||
idEquipo: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Equipo,
|
|
||||||
key: 'idEquipo',
|
|
||||||
},
|
|
||||||
allowNull: true,
|
|
||||||
},
|
|
||||||
idHorario: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Horario,
|
|
||||||
key: 'idHorario',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
idMesa: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Mesa,
|
|
||||||
key: 'idMesa',
|
|
||||||
},
|
|
||||||
allowNull: true,
|
|
||||||
},
|
|
||||||
idSalon: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Salon,
|
|
||||||
key: 'idSalon',
|
|
||||||
},
|
|
||||||
allowNull: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequelize,
|
sequelize,
|
||||||
@@ -93,4 +38,40 @@ Prestamo.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Prestamo.belongsTo(Usuario, {
|
||||||
|
foreignKey: { name: 'idUsuario', type: DataTypes.INTEGER, allowNull: false },
|
||||||
|
})
|
||||||
|
|
||||||
|
Prestamo.belongsTo(Operador, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idOperadorEntrega',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
Prestamo.belongsTo(Operador, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idOperadorRegreso',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
Prestamo.belongsTo(Equipo, {
|
||||||
|
foreignKey: { name: 'idEquipo', type: DataTypes.INTEGER, allowNull: true },
|
||||||
|
})
|
||||||
|
|
||||||
|
Prestamo.belongsTo(Mesa, {
|
||||||
|
foreignKey: { name: 'idMesa', type: DataTypes.INTEGER, allowNull: true },
|
||||||
|
})
|
||||||
|
|
||||||
|
Prestamo.belongsTo(Salon, {
|
||||||
|
foreignKey: { name: 'idSalon', type: DataTypes.INTEGER, allowNull: true },
|
||||||
|
})
|
||||||
|
|
||||||
|
Prestamo.belongsTo(Horario, {
|
||||||
|
foreignKey: { name: 'idHorario', type: DataTypes.INTEGER, allowNull: false },
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = Prestamo
|
module.exports = Prestamo
|
||||||
|
|||||||
@@ -16,14 +16,6 @@ Reporte.init(
|
|||||||
type: DataTypes.STRING(100),
|
type: DataTypes.STRING(100),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
idPrestamo: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Prestamo,
|
|
||||||
key: 'idPrestamo',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequelize,
|
sequelize,
|
||||||
@@ -32,4 +24,8 @@ Reporte.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reporte.belongsTo(Prestamo, {
|
||||||
|
foreignKey: { name: 'idPrestamo', type: DataTypes.INTEGER, allowNull: false },
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = Reporte
|
module.exports = Reporte
|
||||||
|
|||||||
@@ -19,15 +19,7 @@ Salon.init(
|
|||||||
activo: {
|
activo: {
|
||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
|
||||||
idStatus: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: Status,
|
|
||||||
key: 'idStatus',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: 1,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -37,4 +29,13 @@ Salon.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Salon.belongsTo(Status, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idStatus',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 1,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = Salon
|
module.exports = Salon
|
||||||
|
|||||||
+16
-15
@@ -47,21 +47,6 @@ Usuario.init(
|
|||||||
baneado: {
|
baneado: {
|
||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
|
||||||
idCarreraPlantel: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: CarreraPlantel,
|
|
||||||
key: 'idCarreraPlantel',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
idTipoUsuario: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: TipoUsuario,
|
|
||||||
key: 'idTipoUsuario',
|
|
||||||
},
|
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -72,4 +57,20 @@ Usuario.init(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Usuario.belongsTo(TipoUsuario, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idTipoUsuario',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
Usuario.belongsTo(CarreraPlantel, {
|
||||||
|
foreignKey: {
|
||||||
|
name: 'idCarreraPlantel',
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = Usuario
|
module.exports = Usuario
|
||||||
|
|||||||
Reference in New Issue
Block a user