Skip to content

Commit 1ffe9b7

Browse files
mbroadstdaprahamian
authored andcommitted
refactor(client): provide default namespace and read preference
1 parent 778928f commit 1ffe9b7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/mongo_client.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const inherits = require('util').inherits;
88
const MongoError = require('./core').MongoError;
99
const deprecate = require('util').deprecate;
1010
const WriteConcern = require('./write_concern');
11+
const MongoDBNamespace = require('./utils').MongoDBNamespace;
12+
const ReadPreference = require('./core/topologies/read_preference');
1113

1214
// Operations
1315
const ConnectOperation = require('./operations/connect');
@@ -150,7 +152,8 @@ function MongoClient(url, options) {
150152
promiseLibrary: null,
151153
dbCache: new Map(),
152154
sessions: [],
153-
writeConcern: WriteConcern.fromOptions(options)
155+
writeConcern: WriteConcern.fromOptions(options),
156+
namespace: new MongoDBNamespace('admin')
154157
};
155158

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

178+
Object.defineProperty(MongoClient.prototype, 'readPreference', {
179+
enumerable: true,
180+
get: function() {
181+
return ReadPreference.primary;
182+
}
183+
});
184+
175185
/**
176186
* The callback format for results
177187
* @callback MongoClient~connectCallback

0 commit comments

Comments
 (0)