sequelize noobie here so sorry in advance. I am making some Table associations in my app between users posts and comments
Comments Model
import { DataTypes } from 'sequelize';
export const comment = (db) => {
db.define('comment', {
commentContent: {
type: DataTypes.TEXT,
allowNull: false
}
});
}
export const setModelRelationships = (db) => {
const { user, post, comment } = db.models
user.hasMany(post);
user.hasMany(comment);
post.belongsTo(user);
post.hasMany(comment);
comment.belongsTo(post);
comment.belongsTo(user);
}
Checking my db comments has 6 columns:
id | commentContent | createdAt | updatedAt | postId | userId |
if I want to give the postId a custom name such as: commentedOnPostId how can I do this with Sequelize?