Skip to content

Instantly share code, notes, and snippets.

@solisoft
Created August 1, 2011 16:30
Show Gist options
  • Save solisoft/1118461 to your computer and use it in GitHub Desktop.
Save solisoft/1118461 to your computer and use it in GitHub Desktop.
Connexion au ReplicaSet avec Ruby
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