Skip to content

Commit

Permalink
Untransform should treat Array's as nested objects (#1416)
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha authored and drew-gross committed Apr 7, 2016
1 parent 325d09c commit 616ac71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions spec/transform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ describe('untransformObject', () => {
done();
});

it('nested array', (done) => {
var input = {arr: [{_testKey: 'testValue' }]};
var output = transform.untransformObject(dummySchema, null, input);
expect(Array.isArray(output.arr)).toEqual(true);
expect(output.arr).toEqual([{ _testKey: 'testValue'}]);
done();
});

});

describe('transformKey', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ function untransformObject(schema, className, mongoObject, isNestedObject = fals

if (mongoObject instanceof Array) {
return mongoObject.map((o) => {
return untransformObject(schema, className, o);
return untransformObject(schema, className, o, true);
});
}

Expand Down

0 comments on commit 616ac71

Please sign in to comment.