I am new to NodeJs development I am using NodeJs with mysql and Sequelize to create a Batch model with these properties.
const Batch = sequelize.define(
"Batch",
{
title: { type: DataTypes.STRING, allowNull: false },
studentIds: { type: DataTypes.STRING },
teacherId: { type: DataTypes.STRING, allowNull: true }
},
{
timestamps: false
}
);
On async method call it is working fine.
Batch.sync().then((res) => {
console.log("Batch model sync : ", Batch === sequelize.models.Batch);
});
But I need to change
studentIds: { type: DataTypes.ARRAY(DataTypes.STRING)}
Whenever I make this change it gives error
I am using node 14.5.0 MySql 8.0.21 and Sequelize 6.3.4
DataTypes.ARRAY
is not available on Mysql, it's only available on postgres.
Check in official docs: https://sequelize.org/api/v6/class/src/data-types.js~array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With