Skip to content

Sanitize mongo options #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,24 @@ ShareDbMongo.prototype._connect = function(mongo, options) {
mongo(finish);
return;
}
mongodb.connect(mongo, options, finish);
// Get mongo options from the explicitly defined field `mongoOptions` or
// sanitize the whole options object by removing all ShareDB-specific options
// TODO: Deprecate the ability to pass mongo options implicitly
var mongoOptions;
if (options.mongoOptions) {
mongoOptions = options.mongoOptions;
} else {
mongoOptions = Object.assign({}, options);
delete mongoOptions.mongo;
delete mongoOptions.pollDelay;
delete mongoOptions.mongoPoll;
delete mongoOptions.mongoPollOptions;
delete mongoOptions.disableIndexCreation;
delete mongoOptions.allowAllQueries;
delete mongoOptions.allowJSQueries;
delete mongoOptions.allowAggregateQueries;
}
mongodb.connect(mongo, mongoOptions, finish);
};

ShareDbMongo.prototype.close = function(callback) {
Expand Down