Permalink
Browse files

Add support for Write Concern (merges #48)

  • Loading branch information...
1 parent 9445612 commit ffe2be64818dd2df28b6c82115865a86273724ce @kenpratt kenpratt committed Jan 12, 2013
Showing with 10 additions and 5 deletions.
  1. +6 −3 lib/connect-mongo.js
  2. +4 −2 test/connect-mongo.test.js
View
@@ -20,7 +20,8 @@ var defaultOptions = {host: '127.0.0.1',
port: 27017,
stringify: true,
collection: 'sessions',
- auto_reconnect: false};
+ auto_reconnect: false,
+ w: 1};
module.exports = function(connect) {
var Store = connect.session.Store;
@@ -84,7 +85,8 @@ module.exports = function(connect) {
new mongo.Server(options.mongoose_connection.db.serverConfig.host,
options.mongoose_connection.db.serverConfig.port,
options.mongoose_connection.db.serverConfig.options
- ));
+ ),
+ { w: options.w || defaultOptions.w });
} else {
if(!options.db) {
@@ -97,7 +99,8 @@ module.exports = function(connect) {
{
auto_reconnect: options.auto_reconnect ||
defaultOptions.auto_reconnect
- }));
+ }),
+ { w: options.w || defaultOptions.w });
}
this.db_collection_name = options.collection || defaultOptions.collection;
@@ -7,6 +7,7 @@ var connect = require('connect');
var MongoStore = require('../')(connect);
var assert = require('assert');
+var defaultOptions = {w: 1};
var options = {db: 'connect-mongo-test'};
var mongo = require('mongodb');
@@ -36,9 +37,10 @@ var open_db = function(options, callback) {
new mongo.Server(options.mongoose_connection.db.serverConfig.host,
options.mongoose_connection.db.serverConfig.port,
options.mongoose_connection.db.serverConfig.options
- ));
+ ),
+ { w: options.w || defaultOptions.w });
} else {
- db = new mongo.Db(options.db, new mongo.Server('127.0.0.1', 27017, {}));
+ db = new mongo.Db(options.db, new mongo.Server('127.0.0.1', 27017, {}), { w: options.w || defaultOptions.w });
}
if (db.openCalled) {

0 comments on commit ffe2be6

Please sign in to comment.