text: import Sequelize, { Model } from 'sequelize';
  
  class User extends Model {
    static init(sequelize) {
      super.init(
        {
          uid: {
            type: Sequelize.UUID,
            allowNull: false,
            defaultValue: Sequelize.UUIDV4,
            primaryKey: true,
          },
          name: {
            type: Sequelize.STRING,
            allowNull: false,
          },
          email: {
            type: Sequelize.STRING,
            allowNull: false,
            validate: {
              isEmail: true,
            },
          },
        },
        {
          sequelize,
        }
      );
  
      return this;
    }
  
    static associate(models) {
      this.hasMany(models.Post, {
        as: 'posts',
        foreignKey: 'user_uid',
      });
    }
  }
  
  export default User;
  