From 01bf20962b2ebe22ac37211a39ab0ae66c96d7fc Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 30 Oct 2017 15:31:19 -0700 Subject: [PATCH] feat(schema): allow using set as a schema path Fix #1939 --- lib/schema.js | 1 - test/document.test.js | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/schema.js b/lib/schema.js index c9f57ab442e..9ddc9f0febf 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -443,7 +443,6 @@ reserved.get = reserved.modelName = reserved.save = reserved.schema = -reserved.set = reserved.toObject = reserved.validate = reserved.remove = diff --git a/test/document.test.js b/test/document.test.js index 270c8c551b5..3eec0b11b06 100644 --- a/test/document.test.js +++ b/test/document.test.js @@ -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',