Created
          June 12, 2018 18:02 
        
      - 
      
 - 
        
Save jaydestro/cc8ec65d5ada81dd027f6e7f30f2c22d to your computer and use it in GitHub Desktop.  
    ruby and mongodb
  
        
  
    
      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 'mongo' # requires mongoid to be installed | |
| Mongo::Logger.logger.level = ::Logger::FATAL # provides logging output for fails | |
| client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'hackathon') # establishes database connection to localhost, database name hackathon | |
| client.collections.each { |coll| puts coll.name } # does a loop on listing each collection in database and then prints them to standard out | |
| client.close # closes database connection | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment