mongo-ruby-driver/tests/mongo-qa/indices

25 lines
695 B
Plaintext
Raw Normal View History

#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), '_common.rb')
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
x = db.collection('x')
y = db.collection('y')
if __FILE__ == $0
x.drop
x.insert('field1' => 'f1', 'field2' => 'f2')
x.create_index('field1', 'field1')
x.create_index('field2', 'field2')
end
def print_sorted_info_keys(info)
puts info[:keys].keys.sort.collect { |key| "#{key}_1" }.join("_")
end
x.drop_index('field1')
x.index_information.each { |info| print_sorted_info_keys(info) }
y.create_index('abc', ['a', 'b', 'c'])
y.create_index('d', ['d'])
y.index_information.sort{|a,b| a[:name] <=> b[:name]}.each { |info| print_sorted_info_keys(info) }