File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ class Controller {
29
29
'handleReview' ,
30
30
'handlePublish' ,
31
31
'get' ,
32
- 'getExcludedAttributes'
32
+ 'getExcludedAttributes' ,
33
+ 'generateRelationshipAttributeClause'
33
34
) . forEach ( methodName => {
34
35
this [ methodName ] = this [ methodName ] . bind ( this )
35
36
} )
@@ -141,6 +142,14 @@ class Controller {
141
142
return null
142
143
}
143
144
145
+ generateRelationshipAttributeClause ( req , modelName ) {
146
+ if ( ! req ) return null
147
+ const { fields} = req . query
148
+ if ( ! fields ) return null
149
+ const attributes = fields [ modelName ] ? fields [ modelName ] . split ( ',' ) : null
150
+ return attributes
151
+ }
152
+
144
153
// construct a Sorting Condition(value for sequelize sort: key) based on req.query.sort
145
154
generateSortingCondition ( req ) {
146
155
if ( ! req . query . sort ) return [ ]
@@ -177,7 +186,8 @@ class Controller {
177
186
178
187
const includeObj = {
179
188
model : model . target ,
180
- where : this . generateRelationshipWhereClause ( req , modelName )
189
+ where : this . generateRelationshipWhereClause ( req , modelName ) ,
190
+ attributes : this . generateRelationshipAttributeClause ( req , modelName )
181
191
}
182
192
183
193
if ( model . isAliased ) {
You can’t perform that action at this time.
0 commit comments