import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';

class Notification extends Model {
    // Getter für characterName - wird nicht synchronisiert, da es kein Datenbankfeld ist
    get characterName() {
        return this.getDataValue('character_name') || null;
    }
}

Notification.init({
    userId: { 
        type: DataTypes.INTEGER,
        allowNull: false},
    tr: {
        type: DataTypes.STRING,
        allowNull: false},
    character_name: {
        type: DataTypes.STRING,
        allowNull: true,
        field: 'character_name'
    },
    shown: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
        defaultValue: false}}, {
    sequelize,
    modelName: 'Notification',
    tableName: 'notification',
    schema: 'falukant_log',
    timestamps: true,
    underscored: true});

export default Notification;
