diff --git a/lib/helpers/schema/applyWriteConcern.js b/lib/helpers/schema/applyWriteConcern.js index eee4bee51b1..bf5511d55e9 100644 --- a/lib/helpers/schema/applyWriteConcern.js +++ b/lib/helpers/schema/applyWriteConcern.js @@ -6,7 +6,7 @@ module.exports = function applyWriteConcern(schema, options) { const writeConcern = options.writeConcern ? options : get(schema, 'options.writeConcern', {}); if (Object.keys(writeConcern).length != 0) { if (!options.writeConcern) { - options.writeConcern = {}; + options.writeConcern = {}; } if (!('w' in options) && writeConcern.w != null) { options.writeConcern.w = writeConcern.w; diff --git a/test/helpers/applyWriteConcern.test.js b/test/helpers/applyWriteConcern.test.js index fffeaaac6b9..9035ff786cc 100644 --- a/test/helpers/applyWriteConcern.test.js +++ b/test/helpers/applyWriteConcern.test.js @@ -19,15 +19,15 @@ describe('applyWriteConcern', function() { const Test = db.model('Test', testSchema); await Test.create({ name: 'Test Testerson' }); applyWriteConcern(testSchema, options); - assert.deepStrictEqual({ writeConcern: { w:'majority' } }, options); + assert.deepStrictEqual({ writeConcern: { w: 'majority' } }, options); await Test.deleteMany({}, options); - assert.deepStrictEqual({ writeConcern: { w:'majority' } }, options); + assert.deepStrictEqual({ writeConcern: { w: 'majority' } }, options); await Test.deleteMany({}); /** * Because no options were passed in, it is using the schema level writeConcern options. * However, because we are ensuring that user specified options are not being overwritten, * this is the only reasonable way to test this case as our options object should not match the schema options. */ - assert.deepStrictEqual({ writeConcern: { w:'majority' } }, options); + assert.deepStrictEqual({ writeConcern: { w: 'majority' } }, options); }); -}); \ No newline at end of file +});