import { AutoIncrement, Column, CreatedAt, DataType, Min, Model, PrimaryKey, Table, UpdatedAt } from "sequelize-typescript";
import { VISIBILITY } from "../types/common.types";

@Table({
    tableName: 'category',
    timestamps: true,
    paranoid: true,
})
export default class Category extends Model<Category> {
    @PrimaryKey
    @AutoIncrement
    @Column({
        type: DataType.INTEGER({ length: 11 }),
    })
    id!: number;

    @Column({
        type: DataType.STRING({ length: 60 }),
        allowNull: false
    })
    name !: string;

    @Column({
        type: DataType.STRING({ length: 255 }),
        allowNull: true
    })
    logo !: string;

    @Column({
        type: DataType.STRING({ length: 255 }),
        allowNull: true
    })
    banner !: string;

    @Column({
        type: DataType.INTEGER({ length: 3 }),
        validate: {
            min: 0,
            max: 999,
        },
        defaultValue: 0
    })
    rank !: number;

    @Column({
        type: DataType.ENUM(...Object.values(VISIBILITY)),
        defaultValue: VISIBILITY.VISIBLE
    })
    status !: VISIBILITY;
}