Skip to content

Commit

Permalink
feat(schema): allow using set as a schema path
Browse files Browse the repository at this point in the history
Fix #1939
  • Loading branch information
vkarpov15 committed Oct 30, 2017
1 parent 2068a4b commit 01bf209
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ reserved.get =
reserved.modelName =
reserved.save =
reserved.schema =
reserved.set =
reserved.toObject =
reserved.validate =
reserved.remove =
Expand Down
18 changes: 18 additions & 0 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4750,6 +4750,24 @@ describe('document', function() {
});
});

it('Using set as a schema path (gh-1939)', function(done) {
var testSchema = new Schema({ set: String });

var Test = db.model('gh1939', testSchema);

var t = new Test({ set: 'test 1' });
assert.equal(t.set, 'test 1');
t.save(function(error) {
assert.ifError(error);
t.set = 'test 2';
t.save(function(error) {
assert.ifError(error);
assert.equal(t.set, 'test 2');
done();
});
});
});

it('Single nested subdocs using discriminator can be modified (gh-5693)', function(done) {
var eventSchema = new Schema({ message: String }, {
discriminatorKey: 'kind',
Expand Down

0 comments on commit 01bf209

Please sign in to comment.