Created
August 1, 2011 16:30
-
-
Save solisoft/1118461 to your computer and use it in GitHub Desktop.
Connexion au ReplicaSet avec Ruby
This file contains hidden or 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
require "rubygems" | |
require "mongo" # gem install mongo | |
include Mongo | |
@connection = ReplSetConnection.new(['mongo1.mongood.com', 27017], ['mongo2.mongood.com', 27017], ['mongo3.mongood.com', 27017], :read_secondary => true) | |
@connection.add_auth("<base>", "<login>", "<motdepasse>") # Modifiez avec vos informations | |
@connection.apply_saved_authentication() | |
@db = @connection['<base>'] # Modifiez avec le nom de votre base de données | |
@coll = @db['<collection>'] # Modifier avec la collection de votre choix | |
puts @coll.count | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment