Refactor Notification model to remove VIRTUAL field definition for characterName and implement a getter method for improved data handling and synchronization.

This commit is contained in:
Torsten Schulz (local)
2025-12-18 15:43:54 +01:00
parent ea8b9e661d
commit addb8e9a6d

View File

@@ -1,7 +1,12 @@
import { Model, DataTypes } from 'sequelize'; import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js'; import { sequelize } from '../../../utils/sequelize.js';
class Notification extends Model { } 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({ Notification.init({
userId: { userId: {
@@ -15,12 +20,6 @@ Notification.init({
allowNull: true, allowNull: true,
field: 'character_name' field: 'character_name'
}, },
characterName: {
type: DataTypes.VIRTUAL,
get() {
return this.getDataValue('character_name') || null;
}
},
shown: { shown: {
type: DataTypes.BOOLEAN, type: DataTypes.BOOLEAN,
allowNull: false, allowNull: false,