File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,11 @@ class TypeMapper {
5555 result = {
5656 ...ARRAY ,
5757 // Sequelize requires attribute.type to be defined for ARRAYs
58- items : this . map ( { type : properties . type . type , allowNull : false } ) ,
58+ items : this . map (
59+ attributeName ,
60+ { type : properties . type . type , allowNull : false } ,
61+ strategy ,
62+ ) ,
5963 } ;
6064 break ;
6165 }
@@ -323,7 +327,11 @@ class TypeMapper {
323327
324328 case 'VIRTUAL' : {
325329 // Use result for the return type (if defined)
326- result = this . map ( { ...properties , type : properties . type && properties . type . returnType } ) ;
330+ result = this . map (
331+ attributeName ,
332+ { ...properties , type : properties . type && properties . type . returnType } ,
333+ strategy ,
334+ ) ;
327335 break ;
328336 }
329337
Original file line number Diff line number Diff line change @@ -97,6 +97,26 @@ module.exports = sequelize => {
9797 } ;
9898 }
9999
100+ if ( supportedDataType ( 'ARRAY' ) ) {
101+ Model . rawAttributes . ARRAY = {
102+ type : DataTypes . ARRAY ( DataTypes . INTEGER ) ,
103+ } ;
104+ }
105+
106+ if ( supportedDataType ( 'VIRTUAL' ) ) {
107+ Model . rawAttributes . VIRTUAL = {
108+ type : DataTypes . VIRTUAL ( DataTypes . BOOLEAN ) ,
109+ get : ( ) => true ,
110+ } ;
111+
112+ Model . rawAttributes . VIRTUAL_DEPENDENCY = {
113+ type : new DataTypes . VIRTUAL ( DataTypes . INTEGER , [ 'id' ] ) ,
114+ get ( ) {
115+ return this . get ( 'id' ) ;
116+ } ,
117+ } ;
118+ }
119+
100120 // --------------------------------------------------------------------------
101121 // Custom options (as specified through `jsonSchema`) starting below.
102122 // --------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments