Skip to content

Instantly share code, notes, and snippets.

@jhancock
Created August 18, 2009 21:19
Show Gist options
  • Save jhancock/169982 to your computer and use it in GitHub Desktop.
Save jhancock/169982 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')
coll.clear
coll.insert({:sample => "hello", :when => Time.now})
coll.find({}, {:fields => [:sample]}).each {|each| puts each.inspect}
coll.find({}, {:fields => [:sample, :when]}).each {|each| puts each.inspect}
coll.find({}, {:fields => []}).each {|each| puts each.inspect}
coll.find({}, {:fields => nil}).each {|each| puts each.inspect}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment