fixed deprecated api in examples

This commit is contained in:
Kyle Banker 2010-01-05 18:14:48 -05:00
parent 990c00b261
commit 44c7145445
8 changed files with 14 additions and 14 deletions

View File

@ -12,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
coll = db.create_collection('test') coll = db.create_collection('test')
# Erase all records from collection, if any # Erase all records from collection, if any
coll.clear coll.remove
admin = db.admin admin = db.admin

View File

@ -9,7 +9,7 @@ port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Connection::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo::Connection.new(host, port).db('ruby-mongo-examples') db = Mongo::Connection.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
coll.clear coll.remove
OBJS_COUNT = 100 OBJS_COUNT = 100
TEST_COUNT = 100 TEST_COUNT = 100
@ -22,13 +22,13 @@ puts "Running benchmark"
Benchmark.bmbm do |results| Benchmark.bmbm do |results|
results.report("single object inserts: ") { results.report("single object inserts: ") {
TEST_COUNT.times { TEST_COUNT.times {
coll.clear coll.remove
arr.each {|x| coll.insert(x)} arr.each {|x| coll.insert(x)}
} }
} }
results.report("multiple object insert: ") { results.report("multiple object insert: ") {
TEST_COUNT.times { TEST_COUNT.times {
coll.clear coll.remove
coll.insert(arr) coll.insert(arr)
} }
} }
@ -39,4 +39,4 @@ Benchmark.bmbm do |results|
} }
end end
coll.clear coll.remove

View File

@ -21,7 +21,7 @@ LINE_SIZE = 120
puts "=" * LINE_SIZE puts "=" * LINE_SIZE
puts "Adding authors" puts "Adding authors"
authors = DB.collection "authors" authors = DB.collection "authors"
authors.clear authors.remove
authors.create_index "meta", '_id' => 1, 'name' => 1, 'age' => 1 authors.create_index "meta", '_id' => 1, 'name' => 1, 'age' => 1
puts "-" * LINE_SIZE puts "-" * LINE_SIZE
shaksp = authors << { :name => "William Shakespeare", :email => "william@shakespeare.com", :age => 587 } shaksp = authors << { :name => "William Shakespeare", :email => "william@shakespeare.com", :age => 587 }
@ -36,7 +36,7 @@ authors.find({}, :sort => [{'age' => 1}]).each {|x| puts "%-25.25s : %-25.25s :
puts "=" * LINE_SIZE puts "=" * LINE_SIZE
puts "Adding users" puts "Adding users"
users = DB.collection "users" users = DB.collection "users"
users.clear users.remove
# users.create_index "meta", :_id => 1, :login => 1, :name => 1 # users.create_index "meta", :_id => 1, :login => 1, :name => 1
puts "-" * LINE_SIZE puts "-" * LINE_SIZE
jdoe = users << { :login => "jdoe", :name => "John Doe", :email => "john@doe.com" } jdoe = users << { :login => "jdoe", :name => "John Doe", :email => "john@doe.com" }
@ -51,7 +51,7 @@ users.find({}, :sort => [{'login' => 1}]).each {|x| puts "%-10.10s : %-25.25s :
puts "=" * LINE_SIZE puts "=" * LINE_SIZE
puts "Adding articles" puts "Adding articles"
articles = DB.collection "articles" articles = DB.collection "articles"
articles.clear articles.remove
# articles.create_index "meta", :_id => 1, :author_id => 1, :title => 1 # articles.create_index "meta", :_id => 1, :author_id => 1, :title => 1
puts "-" * LINE_SIZE puts "-" * LINE_SIZE
begin begin

View File

@ -12,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Erase all records from collection, if any # Erase all records from collection, if any
coll.clear coll.remove
# Insert 3 records # Insert 3 records
3.times { |i| coll.insert({'a' => i+1}) } 3.times { |i| coll.insert({'a' => i+1}) }

View File

@ -11,7 +11,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Erase all records from collection, if any # Erase all records from collection, if any
coll.clear coll.remove
# Insert 3 records # Insert 3 records
3.times { |i| coll.insert({'a' => i+1}) } 3.times { |i| coll.insert({'a' => i+1}) }

View File

@ -12,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Remove all records, if any # Remove all records, if any
coll.clear coll.remove
# Insert three records # Insert three records
coll.insert('a' => 1) coll.insert('a' => 1)

View File

@ -11,7 +11,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Erase all records from collection, if any # Erase all records from collection, if any
coll.clear coll.remove
# Insert 3 records # Insert 3 records
3.times { |i| coll.insert({'a' => i+1}) } 3.times { |i| coll.insert({'a' => i+1}) }

View File

@ -12,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Remove all records, if any # Remove all records, if any
coll.clear coll.remove
# Insert record with all sorts of values # Insert record with all sorts of values
coll.insert('array' => [1, 2, 3], coll.insert('array' => [1, 2, 3],
@ -32,4 +32,4 @@ coll.insert('array' => [1, 2, 3],
pp coll.find().next_document pp coll.find().next_document
coll.clear coll.remove