Skip to content

Commit

Permalink
update git ignore and option passing
Browse files Browse the repository at this point in the history
  • Loading branch information
willhuang85 committed Nov 10, 2018
1 parent 625d387 commit b8ba036
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ build/Release
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules
.DS_Store
package-lock.json
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const client = (uri, mongoOptions, fn) => {
mongodb.MongoClient.connect(uri, opts, fn);
}

const bucket = (db, options) => {
const opts = Object.assign({}, options.bucketOptions);
const bucket = (db, bucketOptions) => {
const opts = Object.assign({}, bucketOptions);
return new mongodb.GridFSBucket(db, opts);
}

Expand All @@ -35,7 +35,7 @@ module.exports = function SkipperGridFS(globalOptions) {
errorHandler(err, client);
}

bucket(client.db(), options).delete(fd._id, errorHandler);
bucket(client.db(), options.bucketOptions).delete(fd._id, errorHandler);
if (cb) cb();
});
}
Expand All @@ -56,7 +56,7 @@ module.exports = function SkipperGridFS(globalOptions) {
errorHandler(err, client);
}

const cursor = bucket(client.db(), options).find()
const cursor = bucket(client.db(), options.bucketOptions).find()
if (cb) {
cursor.toArray((err, documents) => {
if (err) {
Expand Down Expand Up @@ -98,7 +98,7 @@ module.exports = function SkipperGridFS(globalOptions) {
__transform__.emit('error', error, client);
}

const downloadStream = bucket(client.db(), options).openDownloadStream(fd._id);
const downloadStream = bucket(client.db(), options.bucketOptions).openDownloadStream(fd._id);
downloadStream.once('end', () => {
__transform__.emit('done', client);
});
Expand Down Expand Up @@ -131,7 +131,7 @@ module.exports = function SkipperGridFS(globalOptions) {
const fd = __newFile.fd;
const filename = __newFile.filename;

const __outs = bucket(client.db(), options).openUploadStreamWithId(fd, filename, {
const __outs = bucket(client.db(), options.bucketOptions).openUploadStreamWithId(fd, filename, {
metadata: {
filename: filename,
fd: fd,
Expand Down

0 comments on commit b8ba036

Please sign in to comment.