2009-02-05 19:47:33 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
2009-08-20 22:48:09 +00:00
|
|
|
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
2009-02-05 19:47:33 +00:00
|
|
|
|
2009-02-05 21:00:45 +00:00
|
|
|
if $DEBUG
|
2009-02-05 19:47:33 +00:00
|
|
|
3.times { |i| db.drop_collection("dbs_#{i+1}") }
|
|
|
|
end
|
|
|
|
|
|
|
|
def print_dbs_names(db)
|
|
|
|
db.collection_names.select{ |n| n =~ /\.dbs/ }.sort.each { |name|
|
|
|
|
puts name.sub(/^#{db.name}\./, '')
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
db.collection('dbs_1').insert('foo' => 'bar')
|
|
|
|
db.collection('dbs_2').insert('psi' => 'phi')
|
|
|
|
puts db.name
|
|
|
|
print_dbs_names(db)
|
|
|
|
db.drop_collection('dbs_1')
|
|
|
|
db.create_collection('dbs_3')
|
|
|
|
print_dbs_names(db)
|