I tried to create comment in my post But I can't use
Posts.associate = (models) => {
Posts.hasMany(models.Comments), {
onDelete: "cascade",
}
}
I'm not sure if it's because I myself got the update. "Sequelize.js" is latest so I can't use this command.
I've checked and I can't find any errors.
If you know the correct command you can guide me.
i hope you can help me
models Posts:
module.exports = (sequelize, DataTypes) => {
const Posts = sequelize.define("Posts", {
title: {
type: DataTypes.STRING,
allowNull: false,
},
postText: {
type: DataTypes.STRING,
allowNull: false,
},
username: {
type: DataTypes.STRING,
allowNull: false,
},
});
Posts.associate = (models) => {
Posts.hasMany(models.Comments), {
onDelete: "cascade",
}
}
return Posts;
};
models Comments:
module.exports = (sequelize, DataTypes) => {
const Comments = sequelize.define("Comments", {
commentBody: {
type: DataTypes.STRING,
allowNull: false,
},
});
return Comments;
};