Skip to content

Commit

Permalink
Minor fixes for Mongoclient
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Nov 19, 2012
1 parent 4f232f7 commit af829eb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/mongodb/mongo_client.js
Expand Up @@ -26,9 +26,9 @@ var Db = require('./db').Db;
* @param {Object} [options] additional options for the collection.
*/
function MongoClient(serverConfig, options) {
options = options == null ? {} : options;
options = options === null ? {} : options;
// If no write concern is set set the default to w:1
if(options != null && !options.journal && !options.w && !options.fsync) {
if(options != null && !options.journal && !options.w && !options.fsync) {
options.w = 1;
}

Expand All @@ -43,7 +43,7 @@ function MongoClient(serverConfig, options) {
* @return {null}
* @api public
*/
MongoClient.prototype.open = function(callback) {
MongoClient.prototype.open = function(callback) {
// Self reference
var self = this;

Expand All @@ -60,7 +60,7 @@ MongoClient.prototype.open = function(callback) {
* @return {null}
* @api public
*/
MongoClient.prototype.close = function(callback) {
MongoClient.prototype.close = function(callback) {
this._db.close(callback);
}

Expand All @@ -71,7 +71,7 @@ MongoClient.prototype.close = function(callback) {
* @return {Db} a db instance using the new database.
* @api public
*/
MongoClient.prototype.db = function(dbName) {
MongoClient.prototype.db = function(dbName) {
return this._db.db(dbName);
}

Expand All @@ -93,16 +93,16 @@ MongoClient.prototype.db = function(dbName) {
* @return {null}
* @api public
*/
MongoClient.connect = function(url, options, callback) {
if(typeof options == 'function') {
MongoClient.connect = function(url, options, callback) {
if(typeof options === 'function') {
callback = options;
options = {};
}

Db.connect(url, options, function(err, db) {
if(err) return callback(err, null);
// If no write concern is set set the default to w:1
if(db.options != null && !db.options.safe && !db.options.journal && !db.options.w && !db.options.fsync) {
if(db.options !== null && !db.options.safe && !db.options.journal && !db.options.w && !db.options.fsync) {
db.options.w = 1;
}
// Return the db
Expand Down

0 comments on commit af829eb

Please sign in to comment.