Skip to content

Instantly share code, notes, and snippets.

@jhancock
Created August 12, 2009 18:23
Show Gist options
  • Save jhancock/166653 to your computer and use it in GitHub Desktop.
Save jhancock/166653 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'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
db = XGen::Mongo::Driver::Mongo.new(host, port).db('jon')
coll = db.collection('test')
oid = coll.insert({:dample_data => "helllo", :when => Time.now})
oid_string = oid.to_s
p oid_string
#puts "COUNT: " + coll.count(:_id => oid)
#puts "COUNT: " + coll.count(:_id => XGen::Mongo::Driver::ObjectID.new(oid_string))
puts "COUNT: " + coll.count(:_id => XGen::Mongo::Driver::ObjectID.from_string(oid_string))
cursor = coll.find(:_id => XGen::Mongo::Driver::ObjectID.from_string(oid_string))
#cursor = coll.find(:_id => oid.data)
p cursor.next_object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment