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 136
136
"coverageThreshold" : {
137
137
"global" : {
138
138
"statements" : 93 ,
139
- "branches" : 82 ,
139
+ "branches" : 80 ,
140
140
"functions" : 98 ,
141
141
"lines" : 94
142
142
}
Original file line number Diff line number Diff line change @@ -46,9 +46,14 @@ export default class Transformer {
46
46
? context . getModel ( singularize ( relations . get ( key ) ! . parent ! . entity ) , true )
47
47
: null ;
48
48
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
+ }
52
57
} else if ( typeof value === "object" && value . $id !== undefined ) {
53
58
if ( ! relatedModel ) {
54
59
relatedModel = context . getModel ( ( value as ORMModel ) . $self ( ) . entity ) ;
You can’t perform that action at this time.
0 commit comments