// models/Page.js
const { DataTypes } = require('sequelize');

module.exports = (sequelize) => {
  const Page = sequelize.define('Page', {
    link: {
      type: DataTypes.STRING,
      allowNull: false,
      unique: true
    },
    name: {
      type: DataTypes.STRING,
      allowNull: false
    },
    content: {
      type: DataTypes.TEXT,
      allowNull: true
    }
  }, {
    tableName: 'pages',
    timestamps: true
  });

  Page.associate = (models) => {
    Page.belongsToMany(models.File, { through: 'page_files', foreignKey: 'pageId' });
  };

  return Page;
};
