-
-
Save EchoAbstract/2991961 to your computer and use it in GitHub Desktop.
Node/Mongo Replica set connect string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongo = require 'mongodb' | |
# full connect string | |
mongodbURI = "mongodb:// | |
#{process.env.MONGO_USER}:#{process.env.MONGO_PASSWORD}@ | |
mongoA.company.com,mongoB.company.com,mongoC.company.com/ | |
admin?replicaSet=company&autoReconnect=true&connectTimeoutMS=500" | |
# obtaining a connection is now simple | |
mongo.connect mongodbURI, (err, db) => | |
if (err) | |
throw new Error("Unable to connect to the database") | |
else | |
console.log "Connected" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment