'use strict'; module.exports = function (sequelize, DataTypes) { const Post = sequelize.define('Post', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, }, date: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }, image: { type: DataTypes.STRING, defaultValue: "" }, title: { type: DataTypes.STRING, allowNull: false }, content: { type: DataTypes.TEXT, allowNull: false }, }, { tableName: 'post', freezeTableName: true, timestamps: true, }); Post.associate = function (models) { Post.Categories = Post.belongsToMany(models.Category, { through: models.PostCategory, foreignKey: 'postId' }); Post.Comments = Post.hasMany(models.Comment, { foreignKey: 'postId' }); //Post.Reactions = Post.hasMany(models.PostReaction, { foreignKey: 'postId' }); //Post.User = Post.belongsTo(models.User, { foreignKey: 'userId' }); /* Post.Multimedias = Post.belongsToMany(models.MultimediaFile, { through: models.MultimediaPost, foreignKey: 'postId' }); */ }; return Post; };