diff --git a/.jshintrc b/.jshintrc index cd3db75..bd42fa0 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,10 +1,9 @@ { "bitwise": true, - "browser": true, "camelcase": true, "curly": true, "eqeqeq": true, - "esnext": true, + "esversion": 9, "immed": true, "latedef": true, "newcap": true, @@ -16,4 +15,4 @@ "expr": true, "undef": true, "unused": true -} \ No newline at end of file +} diff --git a/lib/bucket.js b/lib/bucket.js index 01449a3..f886ac1 100644 --- a/lib/bucket.js +++ b/lib/bucket.js @@ -548,9 +548,10 @@ GridFSBucket.prototype._removeFile = function _removeFile(request, file, done) { */ function createBucket(optns = {}) { // ensure options - let { connection, ...options } = optns; - options = _.merge({}, DEFAULT_BUCKET_OPTIONS, optns); + let { connection } = optns; connection = (connection || mongoose.connection); + const options = + _.merge({}, DEFAULT_BUCKET_OPTIONS, _.omit(optns, 'connection')); // check if connection is connected. if (!isConnected(connection)) { @@ -593,7 +594,7 @@ function createBucket(optns = {}) { */ function createModel(optns = {}) { // ensure options - let { connection, modelName, bucketName, ...others } = optns; + let { connection, modelName, bucketName } = optns; connection = (connection || mongoose.connection); modelName = (_.isEmpty(modelName) ? DEFAULT_BUCKET_MODEL_NAME : modelName); bucketName = toCollectionName(modelName); @@ -601,8 +602,9 @@ function createModel(optns = {}) { (modelName === DEFAULT_BUCKET_MODEL_NAME ? DEFAULT_BUCKET_NAME : bucketName); // create bucket - const _options = _.merge({}, { connection, modelName, bucketName }, others); - const bucket = createBucket(_options); + const options = + _.merge({}, { connection, modelName, bucketName }, optns); + const bucket = createBucket(options); // construct model const schema = createSchema(bucket);