File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 136136 "coverageThreshold" : {
137137 "global" : {
138138 "statements" : 93 ,
139- "branches" : 82 ,
139+ "branches" : 80 ,
140140 "functions" : 98 ,
141141 "lines" : 94
142142 }
Original file line number Diff line number Diff line change @@ -46,9 +46,14 @@ export default class Transformer {
4646 ? context . getModel ( singularize ( relations . get ( key ) ! . parent ! . entity ) , true )
4747 : null ;
4848 if ( value instanceof Array ) {
49- // Iterate over all fields and transform them if value is an array
50- const arrayModel = context . getModel ( singularize ( key ) ) ;
51- returnValue [ key ] = value . map ( v => this . transformOutgoingData ( arrayModel || model , v ) ) ;
49+ // Either this is a hasMany field or a .attr() field which contains an array.
50+ const arrayModel = context . getModel ( singularize ( key ) , true ) ;
51+
52+ if ( arrayModel ) {
53+ returnValue [ key ] = value . map ( v => this . transformOutgoingData ( arrayModel || model , v ) ) ;
54+ } else {
55+ returnValue [ key ] = value ;
56+ }
5257 } else if ( typeof value === "object" && value . $id !== undefined ) {
5358 if ( ! relatedModel ) {
5459 relatedModel = context . getModel ( ( value as ORMModel ) . $self ( ) . entity ) ;
You can’t perform that action at this time.
0 commit comments