Skip to content

Commit

Permalink
test(document): repro #6944
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Sep 26, 2018
1 parent 8fea4f8 commit fd8e227
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/document.test.js
Expand Up @@ -6174,4 +6174,23 @@ describe('document', function() {
assert.ok(err.errors['innerField']);
});
});

it('retains user-defined key order with nested docs (gh-6944)', function() {
const schema = new Schema({
_id: String,
foo: String,
bar: {
a: String
}
});

const Model = db.model('gh6944', schema);

const doc = new Model({ _id: 'test', foo: 'hello', bar: { a: 'world' } });

// Same order as in the initial set above
assert.deepEqual(Object.keys(doc._doc), ['_id', 'foo', 'bar']);

return Promise.resolve();
});
});

0 comments on commit fd8e227

Please sign in to comment.