Skip to content

Instantly share code, notes, and snippets.

@jaydestro
Last active June 12, 2018 20:50
Show Gist options
  • Save jaydestro/b2f24df8cc2a50fda95656d692debe5d to your computer and use it in GitHub Desktop.
Save jaydestro/b2f24df8cc2a50fda95656d692debe5d to your computer and use it in GitHub Desktop.
connection w/atlas
require 'mongo' # requires mongoid to be installed
Mongo::Logger.logger.level = ::Logger::FATAL # provides logging output for fails
client = Mongo::Client.new( 'mongodb+srv://admin:[email protected]/hackathon?retryWrites=true' )
#client.collections.each { |coll| puts coll.name } # does a loop on listing each collection in database and then prints them to standard out
cursor = client[:products].find
cursor.each do |doc|
puts doc
end
client.close # closes database connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment