minor: more idiomatic example in README
This commit is contained in:
parent
8534fcd4c6
commit
bfbc71e60f
15
README.md
15
README.md
@ -18,17 +18,18 @@ for much more:
|
|||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'mongo'
|
require 'mongo'
|
||||||
include Mongo
|
|
||||||
|
|
||||||
db = Connection.new.db('sample-db')
|
@conn = Mongo::Connection.new
|
||||||
coll = db.collection('test')
|
@db = @conn['sample-db']
|
||||||
|
@coll = @db['test']
|
||||||
|
|
||||||
coll.remove
|
@coll.remove
|
||||||
3.times do |i|
|
3.times do |i|
|
||||||
coll.insert({'a' => i+1})
|
@coll.insert({'a' => i+1})
|
||||||
end
|
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
|
# Installation
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user