我是NodeJs开发的新手,我在mysql中使用NodeJs,并使用这些属性创建批处理模型。
const Batch = sequelize.define(
"Batch",
{
title: { type: DataTypes.STRING, allowNull: false },
studentIds: { type: DataTypes.STRING },
teacherId: { type: DataTypes.STRING, allowNull: true }
},
{
timestamps: false
}
);在异步方法调用上,它工作得很好。
Batch.sync().then((res) => {
console.log("Batch model sync : ", Batch === sequelize.models.Batch);
});但我需要改变
studentIds: { type: DataTypes.ARRAY(DataTypes.STRING)}每当我做这个改变,它就会出错。

我使用节点14.5.0 MySql 8.0.21并续订6.3.4
发布于 2020-08-10 08:36:43
DataTypes.ARRAY在Mysql上不可用,只能在postgres上使用。
登录官方文档:https://sequelize.org/api/v6/class/src/data-types.js~array
https://stackoverflow.com/questions/63335865
复制相似问题