mongo 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,24 +0,0 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
-
3
- require 'mongo'
4
-
5
- include Mongo
6
-
7
- host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
8
- port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
9
-
10
- puts "Connecting to #{host}:#{port}"
11
- db = Connection.new(host, port).db('ruby-mongo-examples')
12
- coll = db.collection('test')
13
-
14
- # Erase all records from collection, if any
15
- coll.remove
16
-
17
- # Insert 3 records
18
- 3.times { |i| coll.insert({'a' => i+1}) }
19
-
20
- puts "There are #{coll.count()} records in the test collection. Here they are:"
21
- coll.find().each { |doc| puts doc.inspect }
22
-
23
- # Destroy the collection
24
- coll.drop
@@ -1,35 +0,0 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
-
3
- require 'mongo'
4
-
5
- include Mongo
6
-
7
- host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
8
- port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
9
-
10
- puts "Connecting to #{host}:#{port}"
11
- db = Connection.new(host, port).db('ruby-mongo-examples')
12
-
13
- db.drop_collection('does-not-exist')
14
- db.create_collection('test')
15
-
16
- db.strict = true
17
-
18
- begin
19
- # Can't reference collection that does not exist
20
- db.collection('does-not-exist')
21
- puts "error: expected exception"
22
- rescue => ex
23
- puts "expected exception: #{ex}"
24
- end
25
-
26
- begin
27
- # Can't create collection that already exists
28
- db.create_collection('test')
29
- puts "error: expected exception"
30
- rescue => ex
31
- puts "expected exception: #{ex}"
32
- end
33
-
34
- db.strict = false
35
- db.drop_collection('test')
@@ -1,36 +0,0 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
-
3
- require 'mongo'
4
- require 'pp'
5
-
6
- include Mongo
7
-
8
- host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
9
- port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
10
-
11
- puts "Connecting to #{host}:#{port}"
12
- db = Connection.new(host, port).db('ruby-mongo-examples')
13
- coll = db.collection('test')
14
-
15
- # Remove all records, if any
16
- coll.remove
17
-
18
- # Insert record with all sorts of values
19
- coll.insert('array' => [1, 2, 3],
20
- 'string' => 'hello',
21
- 'hash' => {'a' => 1, 'b' => 2},
22
- 'date' => Time.now, # milliseconds only; microseconds are not stored
23
- 'oid' => ObjectID.new,
24
- 'binary' => Binary.new([1, 2, 3]),
25
- 'int' => 42,
26
- 'float' => 33.33333,
27
- 'regex' => /foobar/i,
28
- 'boolean' => true,
29
- 'where' => Code.new('this.x == 3'),
30
- 'dbref' => DBRef.new(coll.name, ObjectID.new),
31
- 'null' => nil,
32
- 'symbol' => :zildjian)
33
-
34
- pp coll.find().next_document
35
-
36
- coll.remove