Sha256: 8205816fd289d8d34863fa8664936c1f0837910e2ece9af17ab01fabbf2aaeb0

Contents?: true

Size: 818 Bytes

Versions: 16

Compression:

Stored size: 818 Bytes

Contents

$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo'

include XGen::Mongo::Driver

host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT

puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples')

db.drop_collection('does-not-exist')
db.create_collection('test')

db.strict = true

begin
  # Can't reference collection that does not exist
  db.collection('does-not-exist')
  puts "error: expected exception"
rescue => ex
  puts "expected exception: #{ex}"
end

begin
  # Can't create collection that already exists
  db.create_collection('test')
  puts "error: expected exception"
rescue => ex
  puts "expected exception: #{ex}"
end

db.strict = false
db.drop_collection('test')

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
animehunter-mongo-0.9 examples/strict.rb
mongodb-mongo-0.10.1 examples/strict.rb
mongodb-mongo-0.10 examples/strict.rb
mongodb-mongo-0.11.1 examples/strict.rb
mongodb-mongo-0.11 examples/strict.rb
mongodb-mongo-0.12 examples/strict.rb
mongodb-mongo-0.6.1 examples/strict.rb
mongodb-mongo-0.6.2 examples/strict.rb
mongodb-mongo-0.6.3 examples/strict.rb
mongodb-mongo-0.6.4 examples/strict.rb
mongodb-mongo-0.6.5 examples/strict.rb
mongodb-mongo-0.6.6 examples/strict.rb
mongodb-mongo-0.6.7 examples/strict.rb
mongodb-mongo-0.7 examples/strict.rb
mongodb-mongo-0.8 examples/strict.rb
mongodb-mongo-0.9 examples/strict.rb