File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,12 @@ function stripNullByte(value) {
2727}
2828sequelize . stripNullByte = stripNullByte ;
2929
30+ function processData ( data , _default , process ) {
31+ if ( data === undefined ) return data ;
32+ else return data === null ? _default : ( process ? process ( data ) : data ) ;
33+ }
34+ sequelize . processData = processData ;
35+
3036var db = { } ;
3137
3238fs
Original file line number Diff line number Diff line change @@ -53,18 +53,27 @@ module.exports = function (sequelize, DataTypes) {
5353 } ,
5454 title : {
5555 type : DataTypes . TEXT ,
56+ get : function ( ) {
57+ return sequelize . processData ( this . getDataValue ( 'title' ) , "" ) ;
58+ } ,
5659 set : function ( value ) {
5760 this . setDataValue ( 'title' , sequelize . stripNullByte ( value ) ) ;
5861 }
5962 } ,
6063 content : {
6164 type : DataTypes . TEXT ,
65+ get : function ( ) {
66+ return sequelize . processData ( this . getDataValue ( 'content' ) , "" ) ;
67+ } ,
6268 set : function ( value ) {
6369 this . setDataValue ( 'content' , sequelize . stripNullByte ( value ) ) ;
6470 }
6571 } ,
6672 authorship : {
6773 type : DataTypes . TEXT ,
74+ get : function ( ) {
75+ return sequelize . processData ( this . getDataValue ( 'authorship' ) , [ ] , JSON . parse ) ;
76+ } ,
6877 set : function ( value ) {
6978 this . setDataValue ( 'authorship' , JSON . stringify ( value ) ) ;
7079 }
Original file line number Diff line number Diff line change @@ -60,18 +60,27 @@ module.exports = function (sequelize, DataTypes) {
6060 } ,
6161 patch : {
6262 type : DataTypes . TEXT ,
63+ get : function ( ) {
64+ return sequelize . processData ( this . getDataValue ( 'patch' ) , "" ) ;
65+ } ,
6366 set : function ( value ) {
6467 this . setDataValue ( 'patch' , sequelize . stripNullByte ( value ) ) ;
6568 }
6669 } ,
6770 lastContent : {
6871 type : DataTypes . TEXT ,
72+ get : function ( ) {
73+ return sequelize . processData ( this . getDataValue ( 'lastContent' ) , "" ) ;
74+ } ,
6975 set : function ( value ) {
7076 this . setDataValue ( 'lastContent' , sequelize . stripNullByte ( value ) ) ;
7177 }
7278 } ,
7379 content : {
7480 type : DataTypes . TEXT ,
81+ get : function ( ) {
82+ return sequelize . processData ( this . getDataValue ( 'content' ) , "" ) ;
83+ } ,
7584 set : function ( value ) {
7685 this . setDataValue ( 'content' , sequelize . stripNullByte ( value ) ) ;
7786 }
@@ -81,6 +90,9 @@ module.exports = function (sequelize, DataTypes) {
8190 } ,
8291 authorship : {
8392 type : DataTypes . TEXT ,
93+ get : function ( ) {
94+ return sequelize . processData ( this . getDataValue ( 'authorship' ) , [ ] , JSON . parse ) ;
95+ } ,
8496 set : function ( value ) {
8597 this . setDataValue ( 'authorship' , value ? JSON . stringify ( value ) : value ) ;
8698 }
You can’t perform that action at this time.
0 commit comments