Skip to content

Instantly share code, notes, and snippets.

@TwP
Created January 19, 2010 18:36
Show Gist options
  • Save TwP/281150 to your computer and use it in GitHub Desktop.
Save TwP/281150 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'mongo'
connection = Mongo::Connection.new
database = connection.db 'oddball'
collection = database.create_collection('foo', :capped => true, :size => 10 * 1024 * 1024)
docs = []
100.times {|n| docs << {'count' => n, 'time' => Time.now.utc.to_s}}
collection.insert docs
doc = collection.find_one
puts "class: #{doc['_id'].class.name}, id: #{doc['_id'].inspect}"
puts collection.find_one(doc['_id']).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment