From 2fb97e2c590ea317b21fe4b0861a9d79c877a12f Mon Sep 17 00:00:00 2001 From: Timothy Marks Date: Tue, 7 Aug 2012 12:13:11 +1000 Subject: [PATCH] Adds Replica Set Support to JugglingDB Mongoose Adapter --- lib/adapters/mongoose.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/adapters/mongoose.js b/lib/adapters/mongoose.js index 231c515f..2609d638 100644 --- a/lib/adapters/mongoose.js +++ b/lib/adapters/mongoose.js @@ -29,7 +29,12 @@ exports.initialize = function initializeSchema(schema, callback) { url = 'mongodb://' + url; schema.settings.url = url; } - schema.client = mongoose.connect(schema.settings.url); + if (!schema.settings.rs) { + schema.client = mongoose.connect(schema.settings.url); + } else { + schema.client = mongoose.connectSet(schema.settings.url, {rs_name: schema.settings.rs}); + } + schema.adapter = new MongooseAdapter(schema.client); process.nextTick(callback); };