Skip to content

Commit 616ac71

Browse files
blachadrew-gross
authored andcommitted
Untransform should treat Array's as nested objects (#1416)
1 parent 325d09c commit 616ac71

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

spec/transform.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ describe('untransformObject', () => {
147147
done();
148148
});
149149

150+
it('nested array', (done) => {
151+
var input = {arr: [{_testKey: 'testValue' }]};
152+
var output = transform.untransformObject(dummySchema, null, input);
153+
expect(Array.isArray(output.arr)).toEqual(true);
154+
expect(output.arr).toEqual([{ _testKey: 'testValue'}]);
155+
done();
156+
});
157+
150158
});
151159

152160
describe('transformKey', () => {

src/transform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ function untransformObject(schema, className, mongoObject, isNestedObject = fals
633633

634634
if (mongoObject instanceof Array) {
635635
return mongoObject.map((o) => {
636-
return untransformObject(schema, className, o);
636+
return untransformObject(schema, className, o, true);
637637
});
638638
}
639639

0 commit comments

Comments
 (0)