Sha256: c2dd0f9aa1eea4ca23714e08d72192e8542c4431de274a7e357102da17f84a80

Contents?: true

Size: 788 Bytes

Versions: 23

Compression:

Stored size: 788 Bytes

Contents

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'mongo'

include Mongo

host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT

puts "Connecting to #{host}:#{port}"
db = Connection.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

23 entries across 23 versions & 3 rubygems

Version Path
mongo-1.1.1 examples/strict.rb
mongo-1.1 examples/strict.rb
mongo-1.0.9 examples/strict.rb
mongo-1.0.8 examples/strict.rb
mongo-1.0.7 examples/strict.rb
mongo-1.0.6 examples/strict.rb
mongo-1.0.5 examples/strict.rb
mongo-1.0.4 examples/strict.rb
mongo-1.0.3 examples/strict.rb
mongo-1.0.2 examples/strict.rb
mongo-1.0.1 examples/strict.rb
mongo-1.0 examples/strict.rb
mongo-0.20.1 examples/strict.rb
mongo-0.20 examples/strict.rb
mongo-0.19.3 examples/strict.rb
mongo-0.19.2 examples/strict.rb
mongo-0.19.1 examples/strict.rb
mongo-0.19 examples/strict.rb
kbaum-mongo-0.19 examples/strict.rb
kbaum-mongo-0.18.3.2 examples/strict.rb