Refactor data processing to model definition
This commit is contained in:
@@ -53,18 +53,27 @@ module.exports = function (sequelize, DataTypes) {
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.TEXT,
|
||||
get: function () {
|
||||
return sequelize.processData(this.getDataValue('title'), "");
|
||||
},
|
||||
set: function (value) {
|
||||
this.setDataValue('title', sequelize.stripNullByte(value));
|
||||
}
|
||||
},
|
||||
content: {
|
||||
type: DataTypes.TEXT,
|
||||
get: function () {
|
||||
return sequelize.processData(this.getDataValue('content'), "");
|
||||
},
|
||||
set: function (value) {
|
||||
this.setDataValue('content', sequelize.stripNullByte(value));
|
||||
}
|
||||
},
|
||||
authorship: {
|
||||
type: DataTypes.TEXT,
|
||||
get: function () {
|
||||
return sequelize.processData(this.getDataValue('authorship'), [], JSON.parse);
|
||||
},
|
||||
set: function (value) {
|
||||
this.setDataValue('authorship', JSON.stringify(value));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user