fixed deprecated api in examples
This commit is contained in:
parent
990c00b261
commit
44c7145445
@ -12,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||
coll = db.create_collection('test')
|
||||
|
||||
# Erase all records from collection, if any
|
||||
coll.clear
|
||||
coll.remove
|
||||
|
||||
admin = db.admin
|
||||
|
||||
|
@ -9,7 +9,7 @@ port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Connection::DEFAULT_PORT
|
||||
puts "Connecting to #{host}:#{port}"
|
||||
db = Mongo::Connection.new(host, port).db('ruby-mongo-examples')
|
||||
coll = db.collection('test')
|
||||
coll.clear
|
||||
coll.remove
|
||||
|
||||
OBJS_COUNT = 100
|
||||
TEST_COUNT = 100
|
||||
@ -22,13 +22,13 @@ puts "Running benchmark"
|
||||
Benchmark.bmbm do |results|
|
||||
results.report("single object inserts: ") {
|
||||
TEST_COUNT.times {
|
||||
coll.clear
|
||||
coll.remove
|
||||
arr.each {|x| coll.insert(x)}
|
||||
}
|
||||
}
|
||||
results.report("multiple object insert: ") {
|
||||
TEST_COUNT.times {
|
||||
coll.clear
|
||||
coll.remove
|
||||
coll.insert(arr)
|
||||
}
|
||||
}
|
||||
@ -39,4 +39,4 @@ Benchmark.bmbm do |results|
|
||||
}
|
||||
end
|
||||
|
||||
coll.clear
|
||||
coll.remove
|
||||
|
@ -21,7 +21,7 @@ LINE_SIZE = 120
|
||||
puts "=" * LINE_SIZE
|
||||
puts "Adding authors"
|
||||
authors = DB.collection "authors"
|
||||
authors.clear
|
||||
authors.remove
|
||||
authors.create_index "meta", '_id' => 1, 'name' => 1, 'age' => 1
|
||||
puts "-" * LINE_SIZE
|
||||
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 "Adding users"
|
||||
users = DB.collection "users"
|
||||
users.clear
|
||||
users.remove
|
||||
# users.create_index "meta", :_id => 1, :login => 1, :name => 1
|
||||
puts "-" * LINE_SIZE
|
||||
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 "Adding articles"
|
||||
articles = DB.collection "articles"
|
||||
articles.clear
|
||||
articles.remove
|
||||
# articles.create_index "meta", :_id => 1, :author_id => 1, :title => 1
|
||||
puts "-" * LINE_SIZE
|
||||
begin
|
||||
|
@ -12,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||
coll = db.collection('test')
|
||||
|
||||
# Erase all records from collection, if any
|
||||
coll.clear
|
||||
coll.remove
|
||||
|
||||
# Insert 3 records
|
||||
3.times { |i| coll.insert({'a' => i+1}) }
|
||||
|
@ -11,7 +11,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||
coll = db.collection('test')
|
||||
|
||||
# Erase all records from collection, if any
|
||||
coll.clear
|
||||
coll.remove
|
||||
|
||||
# Insert 3 records
|
||||
3.times { |i| coll.insert({'a' => i+1}) }
|
||||
|
@ -12,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||
coll = db.collection('test')
|
||||
|
||||
# Remove all records, if any
|
||||
coll.clear
|
||||
coll.remove
|
||||
|
||||
# Insert three records
|
||||
coll.insert('a' => 1)
|
||||
|
@ -11,7 +11,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||
coll = db.collection('test')
|
||||
|
||||
# Erase all records from collection, if any
|
||||
coll.clear
|
||||
coll.remove
|
||||
|
||||
# Insert 3 records
|
||||
3.times { |i| coll.insert({'a' => i+1}) }
|
||||
|
@ -12,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
||||
coll = db.collection('test')
|
||||
|
||||
# Remove all records, if any
|
||||
coll.clear
|
||||
coll.remove
|
||||
|
||||
# Insert record with all sorts of values
|
||||
coll.insert('array' => [1, 2, 3],
|
||||
@ -32,4 +32,4 @@ coll.insert('array' => [1, 2, 3],
|
||||
|
||||
pp coll.find().next_document
|
||||
|
||||
coll.clear
|
||||
coll.remove
|
||||
|
Loading…
Reference in New Issue
Block a user