create and update data

12 views
Skip to first unread message

Tomás

unread,
Jan 3, 2020, 11:22:15 AM1/3/20
to Sequelize
Hello, 
I have some problems with these models to create or update records.

I don't know How to create a record, on center table  and associate with  a record on table bussine  if on table Bussines  exist this record.
 
I'm very new on sequelize 
Kinds REgards


//BussinesModel

module.exports = (config) => {
const sequelize = setupDatabase(config)

return sequelize.define('empresa', {
name :{
type: Sequelize.STRING
},
active: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true
}
})
}

//CenterModel

module.exports = (config) => {
const sequelize = setupDatabase(config)

return sequelize.define('centro', {
name :{
type: Sequelize.STRING
},
active: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true
}
})
}


EmpresaModel.hasMany(CentroModel)
CentroModel.belongsTo(EmpresaModel)






Reply all
Reply to author
Forward
0 new messages