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:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user