Skip to content

Commit

Permalink
refactor(client): provide default namespace and read preference
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst authored and daprahamian committed Aug 13, 2019
1 parent 778928f commit 1ffe9b7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/mongo_client.js
Expand Up @@ -8,6 +8,8 @@ const inherits = require('util').inherits;
const MongoError = require('./core').MongoError;
const deprecate = require('util').deprecate;
const WriteConcern = require('./write_concern');
const MongoDBNamespace = require('./utils').MongoDBNamespace;
const ReadPreference = require('./core/topologies/read_preference');

// Operations
const ConnectOperation = require('./operations/connect');
Expand Down Expand Up @@ -150,7 +152,8 @@ function MongoClient(url, options) {
promiseLibrary: null,
dbCache: new Map(),
sessions: [],
writeConcern: WriteConcern.fromOptions(options)
writeConcern: WriteConcern.fromOptions(options),
namespace: new MongoDBNamespace('admin')
};

// Get the promiseLibrary
Expand All @@ -172,6 +175,13 @@ Object.defineProperty(MongoClient.prototype, 'writeConcern', {
}
});

Object.defineProperty(MongoClient.prototype, 'readPreference', {
enumerable: true,
get: function() {
return ReadPreference.primary;
}
});

/**
* The callback format for results
* @callback MongoClient~connectCallback
Expand Down

0 comments on commit 1ffe9b7

Please sign in to comment.