minor: more idiomatic example in README

This commit is contained in:
Kyle Banker 2011-04-04 11:24:27 -04:00
parent 8534fcd4c6
commit bfbc71e60f
1 changed files with 8 additions and 7 deletions

View File

@ -18,17 +18,18 @@ for much more:
require 'rubygems'
require 'mongo'
include Mongo
db = Connection.new.db('sample-db')
coll = db.collection('test')
@conn = Mongo::Connection.new
@db = @conn['sample-db']
@coll = @db['test']
coll.remove
@coll.remove
3.times do |i|
coll.insert({'a' => i+1})
@coll.insert({'a' => i+1})
end
puts "There are #{coll.count()} records. Here they are:"
coll.find().each { |doc| puts doc.inspect }
puts "There are #{@coll.count} records. Here they are:"
@coll.find.each { |doc| puts doc.inspect }
# Installation