Skip to content

Commit

Permalink
refactor(lint): update lint & fix sources
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Apr 27, 2019
1 parent 7dbfa83 commit 8fed534
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 2 additions & 3 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"bitwise": true,
"browser": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"esnext": true,
"esversion": 9,
"immed": true,
"latedef": true,
"newcap": true,
Expand All @@ -16,4 +15,4 @@
"expr": true,
"undef": true,
"unused": true
}
}
12 changes: 7 additions & 5 deletions lib/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -593,16 +594,17 @@ 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);
bucketName =
(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);
Expand Down

0 comments on commit 8fed534

Please sign in to comment.