diff options
author | Wu Cheng-Han | 2017-01-02 11:05:05 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2017-01-02 11:05:05 +0800 |
commit | d9e19b602968551fcda4ee806d767a04f6a11490 (patch) | |
tree | 788b3f708545b2875f115c5716b7849c1cc9ad03 /lib/models/note.js | |
parent | c3a96ff112c8f7ea31af97fbc3319e782f4490e2 (diff) |
Update to remove null byte before saving to DB and remove null byte on changes
Diffstat (limited to 'lib/models/note.js')
-rw-r--r-- | lib/models/note.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/models/note.js b/lib/models/note.js index 81de991f..37d26ec0 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -52,13 +52,22 @@ module.exports = function (sequelize, DataTypes) { defaultValue: 0 }, title: { - type: DataTypes.TEXT + type: DataTypes.TEXT, + set: function (value) { + this.setDataValue('title', sequelize.stripNullByte(value)); + } }, content: { - type: DataTypes.TEXT + type: DataTypes.TEXT, + set: function (value) { + this.setDataValue('content', sequelize.stripNullByte(value)); + } }, authorship: { - type: DataTypes.TEXT + type: DataTypes.TEXT, + set: function (value) { + this.setDataValue('authorship', JSON.stringify(value)); + } }, lastchangeAt: { type: DataTypes.DATE |