Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions packages/mongo/connection_options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @summary Allows for user specified connection options
* @example http://mongodb.github.io/node-mongodb-native/2.1/reference/connecting/connection-settings/
* @locus Server
* @param {Object} options User specified Mongo connection options
*/
Mongo.setConnectionOptions = function setConnectionOptions (options) {
check(options, Object);
Mongo._connectionOptions = options;
}
7 changes: 4 additions & 3 deletions packages/mongo/mongo_driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ MongoConnection = function (url, options) {
self._observeMultiplexers = {};
self._onFailoverHook = new Hook;

var mongoOptions = {db: {safe: true}, server: {}, replSet: {}};
var mongoOptions = _.extend({db: {safe: true}, server: {}, replSet: {}},
Mongo._connectionOptions);

// Set autoReconnect to true, unless passed on the URL. Why someone
// would want to set autoReconnect to false, I'm not really sure, but
Expand All @@ -151,8 +152,8 @@ MongoConnection = function (url, options) {
mongoOptions.db.native_parser = false;
}

// XXX maybe we should have a better way of allowing users to configure the
// underlying Mongo driver
// Internally the oplog connections specify their own poolSize
// which we don't want to overwrite with any user defined value
if (_.has(options, 'poolSize')) {
// If we just set this for "server", replSet will override it. If we just
// set it for replSet, it will be ignored if we're not using a replSet.
Expand Down
1 change: 1 addition & 0 deletions packages/mongo/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Package.onUse(function (api) {
api.addFiles('local_collection_driver.js', ['client', 'server']);
api.addFiles('remote_collection_driver.js', 'server');
api.addFiles('collection.js', ['client', 'server']);
api.addFiles('connection_options.js', 'server');
});

Package.onTest(function (api) {
Expand Down