Skip to content

Instantly share code, notes, and snippets.

@gtcarlos
Created February 1, 2013 01:20
Show Gist options
  • Save gtcarlos/4688366 to your computer and use it in GitHub Desktop.
Save gtcarlos/4688366 to your computer and use it in GitHub Desktop.
Ruby code to connect to the database MongoDB and select first one.
require 'mongo'
include Mongo
@client = MongoClient.new('localhost', 27017)
@db = @client['test']
@names = @db['names']
item = @names.find_one()
puts item['name']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment