Skip to content

Instantly share code, notes, and snippets.

@jhancock
Created August 20, 2009 19:02
Show Gist options
  • Save jhancock/171269 to your computer and use it in GitHub Desktop.
Save jhancock/171269 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'mongo'
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
db = Mongo::Mongo.new(host, port).db('jon')
coll = db.collection('test')
coll.clear
coll.insert({:sample => "hello", :when => Time.now})
coll.insert({:sample => "goodbye", :when => Time.now})
coll.find().each {|each| puts each['_id'].to_s}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment