mongo 0.18.2 → 0.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +37 -28
- data/Rakefile +19 -0
- data/bin/objectid_benchmark.rb +23 -0
- data/examples/admin.rb +7 -6
- data/examples/capped.rb +3 -4
- data/examples/cursor.rb +4 -3
- data/examples/gridfs.rb +3 -2
- data/examples/index_test.rb +10 -9
- data/examples/info.rb +3 -2
- data/examples/queries.rb +3 -2
- data/examples/simple.rb +3 -2
- data/examples/strict.rb +2 -1
- data/examples/types.rb +4 -3
- data/lib/mongo.rb +29 -12
- data/lib/mongo/admin.rb +17 -2
- data/lib/mongo/collection.rb +230 -169
- data/lib/mongo/connection.rb +136 -91
- data/lib/mongo/cursor.rb +68 -40
- data/lib/mongo/db.rb +247 -123
- data/lib/mongo/{errors.rb → exceptions.rb} +6 -5
- data/lib/mongo/gridfs.rb +6 -0
- data/lib/mongo/gridfs/grid_store.rb +142 -94
- data/lib/mongo/types/binary.rb +11 -1
- data/lib/mongo/types/code.rb +6 -1
- data/lib/mongo/types/dbref.rb +7 -2
- data/lib/mongo/types/min_max_keys.rb +58 -0
- data/lib/mongo/types/objectid.rb +76 -20
- data/lib/mongo/types/regexp_of_holding.rb +5 -0
- data/lib/mongo/util/bson_ruby.rb +36 -2
- data/lib/mongo/util/byte_buffer.rb +18 -2
- data/lib/mongo/util/conversions.rb +6 -5
- data/lib/mongo/util/ordered_hash.rb +3 -1
- data/lib/mongo/util/support.rb +3 -0
- data/lib/mongo/util/xml_to_ruby.rb +7 -0
- data/test/test_bson.rb +48 -0
- data/test/test_collection.rb +13 -0
- data/test/test_connection.rb +35 -0
- data/test/test_conversions.rb +1 -1
- data/test/test_cursor.rb +37 -5
- data/test/test_db.rb +51 -2
- data/test/test_db_api.rb +4 -7
- data/test/test_grid_store.rb +10 -0
- data/test/test_objectid.rb +16 -2
- data/test/test_ordered_hash.rb +14 -0
- data/test/threading/test_threading_large_pool.rb +4 -4
- data/test/unit/db_test.rb +43 -0
- metadata +5 -7
- data/examples/benchmarks.rb +0 -42
- data/examples/blog.rb +0 -76
- data/lib/mongo/constants.rb +0 -15
- data/test/mongo-qa/_common.rb +0 -8
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
This is the 10gen-supported Ruby driver for MongoDB[http://www.mongodb.org].
|
4
4
|
|
5
|
-
Here
|
5
|
+
Here's a quick code sample. See the MongoDB Ruby Tutorial
|
6
6
|
(http://www.mongodb.org/display/DOCS/Ruby+Tutorial) for much more.
|
7
7
|
|
8
8
|
require 'rubygems'
|
@@ -56,7 +56,7 @@ That's all there is to it!
|
|
56
56
|
For extensive examples, see the MongoDB Ruby Tutorial
|
57
57
|
(http://www.mongodb.org/display/DOCS/Ruby+Tutorial).
|
58
58
|
|
59
|
-
Bundled with the
|
59
|
+
Bundled with the driver are many examples, located in the "examples" subdirectory. Samples include using
|
60
60
|
the driver and using the GridFS class GridStore. MongoDB must be running for
|
61
61
|
these examples to work, of course.
|
62
62
|
|
@@ -82,25 +82,34 @@ Note that the GridStore class is not automatically required when you require
|
|
82
82
|
|
83
83
|
Example code:
|
84
84
|
|
85
|
-
|
85
|
+
include GridFS
|
86
|
+
|
87
|
+
# Store the text "Hello, world!" in the grid store.
|
88
|
+
GridStore.open(database, 'filename', 'w') do |f|
|
86
89
|
f.puts "Hello, world!"
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
end
|
91
|
+
|
92
|
+
# Output "Hello, world!"
|
93
|
+
GridStore.open(database, 'filename', 'r') do |f|
|
94
|
+
puts f.read
|
95
|
+
end
|
96
|
+
|
97
|
+
# Add text to the grid store.
|
98
|
+
GridStore.open(database, 'filename', 'w+') do |f|
|
92
99
|
f.puts "But wait, there's more!"
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
100
|
+
end
|
101
|
+
|
102
|
+
# Retrieve everything, outputting "Hello, world!\nBut wait, there's more!\n"
|
103
|
+
GridStore.open(database, 'filename', 'r') do |f|
|
104
|
+
puts f.read
|
105
|
+
end
|
97
106
|
|
98
107
|
|
99
108
|
= Notes
|
100
109
|
|
101
110
|
== Thread Safety
|
102
111
|
|
103
|
-
The driver is thread
|
112
|
+
The driver is thread-safe.
|
104
113
|
|
105
114
|
== Connection Pooling
|
106
115
|
|
@@ -119,7 +128,7 @@ A pooled connection to a paired instance would look like this:
|
|
119
128
|
:right => ["db2.example.com", 27017]}, nil,
|
120
129
|
:pool_size => 20, :timeout => 5)
|
121
130
|
|
122
|
-
Though the pooling
|
131
|
+
Though the pooling architecture will undoubtedly evolve, it currently owes much credit
|
123
132
|
to the connection pooling implementations in ActiveRecord and PyMongo.
|
124
133
|
|
125
134
|
== Using with Phusion Passenger
|
@@ -139,7 +148,7 @@ or handle reconnecting when passenger forks a new process:
|
|
139
148
|
end
|
140
149
|
end
|
141
150
|
|
142
|
-
The above code should be put in _environment.rb_ or an initialization
|
151
|
+
The above code should be put in _environment.rb_ or in an initialization
|
143
152
|
script.
|
144
153
|
|
145
154
|
See this thread[http://groups.google.com/group/mongodb-user/browse_thread/thread/f31e2d23de38136a]
|
@@ -156,7 +165,7 @@ read from Mongo will have their character encodings set to UTF-8.
|
|
156
165
|
|
157
166
|
When used with Ruby 1.8, the bytes in each string are written to and read from
|
158
167
|
Mongo as-is. If the string is ASCII all is well, because ASCII is a subset of
|
159
|
-
UTF-8. If the string is not ASCII
|
168
|
+
UTF-8. If the string is not ASCII, it may not be a well-formed UTF-8
|
160
169
|
string.
|
161
170
|
|
162
171
|
== Primary Keys
|
@@ -173,17 +182,18 @@ generate _id values. If you want to control _id values or even their types,
|
|
173
182
|
using a PK factory lets you do so.
|
174
183
|
|
175
184
|
You can tell the Ruby Mongo driver how to create primary keys by passing in
|
176
|
-
the :
|
185
|
+
the :pk_factory option to the Connection#db method.
|
177
186
|
|
178
|
-
|
179
|
-
db = Connection.new.db('dbname', :pk => MyPKFactory.new)
|
187
|
+
db = Mongo::Connection.new.db('dbname', :pk_factory => MyPKFactory.new)
|
180
188
|
|
181
189
|
A primary key factory object must respond to :create_pk, which should take a
|
182
190
|
hash and return a hash which merges the original hash with any primary key
|
183
|
-
fields the factory wishes to inject.
|
184
|
-
|
185
|
-
|
186
|
-
a
|
191
|
+
fields the factory wishes to inject.
|
192
|
+
|
193
|
+
NOTE: if the object already has a primary key, the factory should not inject
|
194
|
+
a new key; this means that the object may already exist in the database.
|
195
|
+
The idea here is that whenever a record is inserted,
|
196
|
+
the :pk_factory object's +create_pk+ method will be called and
|
187
197
|
the new hash returned will be inserted.
|
188
198
|
|
189
199
|
Here is a sample primary key factory, taken from the tests:
|
@@ -251,11 +261,10 @@ Random cursor fun facts:
|
|
251
261
|
- Cursors have a to_a method.
|
252
262
|
|
253
263
|
|
254
|
-
|
255
264
|
= Testing
|
256
265
|
|
257
266
|
If you have the source code, you can run the tests. There's a separate rake task for testing with
|
258
|
-
the mongo_ext
|
267
|
+
the mongo_ext C extension enabled.
|
259
268
|
|
260
269
|
$ rake test:c
|
261
270
|
|
@@ -268,7 +277,7 @@ These will run both unit and functional tests. To run these tests alone:
|
|
268
277
|
$ rake test:unit
|
269
278
|
$ rake test:functional
|
270
279
|
|
271
|
-
To run any individual rake tasks with the C
|
280
|
+
To run any individual rake tasks with the C extension enabled, just pass C_EXT=true to the task:
|
272
281
|
|
273
282
|
$ rake test:unit C_EXT=true
|
274
283
|
|
@@ -318,9 +327,9 @@ validator script.
|
|
318
327
|
This documentation is available online at http://api.mongodb.org/ruby. You can
|
319
328
|
generate the documentation if you have the source by typing
|
320
329
|
|
321
|
-
$ rake
|
330
|
+
$ rake ydoc
|
322
331
|
|
323
|
-
Then open the file
|
332
|
+
Then open the file +ydoc/index.html+.
|
324
333
|
|
325
334
|
|
326
335
|
= Release Notes
|
data/Rakefile
CHANGED
@@ -28,6 +28,7 @@ namespace :test do
|
|
28
28
|
Rake::Task['test:unit'].invoke
|
29
29
|
Rake::Task['test:functional'].invoke
|
30
30
|
Rake::Task['test:pooled_threading'].invoke
|
31
|
+
Rake::Task['test:drop_databases'].invoke
|
31
32
|
ENV['C_EXT'] = nil
|
32
33
|
end
|
33
34
|
|
@@ -37,6 +38,7 @@ namespace :test do
|
|
37
38
|
Rake::Task['test:unit'].invoke
|
38
39
|
Rake::Task['test:functional'].invoke
|
39
40
|
Rake::Task['test:pooled_threading'].invoke
|
41
|
+
Rake::Task['test:drop_databases'].invoke
|
40
42
|
end
|
41
43
|
|
42
44
|
Rake::TestTask.new(:unit) do |t|
|
@@ -73,6 +75,15 @@ namespace :test do
|
|
73
75
|
t.test_files = FileList['test/replica/query_test.rb']
|
74
76
|
t.verbose = true
|
75
77
|
end
|
78
|
+
|
79
|
+
task :drop_databases do |t|
|
80
|
+
puts "Dropping test database..."
|
81
|
+
require File.join(File.dirname(__FILE__), 'lib', 'mongo')
|
82
|
+
include Mongo
|
83
|
+
con = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
84
|
+
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT)
|
85
|
+
con.drop_database('ruby-mongo-test')
|
86
|
+
end
|
76
87
|
end
|
77
88
|
|
78
89
|
desc "Generate documentation"
|
@@ -83,6 +94,14 @@ task :rdoc do
|
|
83
94
|
system "rdoc --main README.rdoc --op #{out} --inline-source --quiet README.rdoc `find lib -name '*.rb'`"
|
84
95
|
end
|
85
96
|
|
97
|
+
desc "Generate YARD documentation"
|
98
|
+
task :ydoc do
|
99
|
+
version = eval(File.read("mongo-ruby-driver.gemspec")).version
|
100
|
+
out = File.join('ydoc', version.to_s)
|
101
|
+
FileUtils.rm_rf('ydoc')
|
102
|
+
system "yardoc lib/**/*.rb lib/mongo/**/*.rb -o #{out} --title MongoRuby-#{version}"
|
103
|
+
end
|
104
|
+
|
86
105
|
desc "Publish documentation to mongo.rubyforge.org"
|
87
106
|
task :publish => [:rdoc] do
|
88
107
|
# Assumes docs are in ./html
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mongo'
|
3
|
+
require 'benchmark'
|
4
|
+
|
5
|
+
TRIALS = 500000
|
6
|
+
|
7
|
+
include Mongo
|
8
|
+
|
9
|
+
Benchmark.bm do |x|
|
10
|
+
|
11
|
+
x.report('original') do
|
12
|
+
TRIALS.times do
|
13
|
+
ObjectID.new(nil, true)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
x.report('new') do
|
18
|
+
TRIALS.times do
|
19
|
+
ObjectID.new(nil, false)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/examples/admin.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
2
3
|
require 'mongo'
|
3
4
|
require 'pp'
|
4
5
|
|
@@ -8,16 +9,16 @@ host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
|
8
9
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
9
10
|
|
10
11
|
puts "Connecting to #{host}:#{port}"
|
11
|
-
db = Connection.new(host, port).db('ruby-mongo-examples')
|
12
|
+
db = Mongo::Connection.new(host, port).db('ruby-mongo-examples')
|
12
13
|
coll = db.create_collection('test')
|
13
14
|
|
14
15
|
# Erase all records from collection, if any
|
15
|
-
coll.
|
16
|
+
coll.remove
|
16
17
|
|
17
18
|
admin = db.admin
|
18
19
|
|
19
20
|
# Profiling level set/get
|
20
|
-
|
21
|
+
puts "Profiling level: #{admin.profiling_level}"
|
21
22
|
|
22
23
|
# Start profiling everything
|
23
24
|
admin.profiling_level = :all
|
@@ -31,8 +32,8 @@ admin.profiling_level = :off
|
|
31
32
|
# Print all profiling info
|
32
33
|
pp admin.profiling_info
|
33
34
|
|
34
|
-
# Validate returns a hash if all is well
|
35
|
-
# problem.
|
35
|
+
# Validate returns a hash if all is well and
|
36
|
+
# raises an exception if there is a problem.
|
36
37
|
info = admin.validate_collection(coll.name)
|
37
38
|
puts "valid = #{info['ok']}"
|
38
39
|
puts info['result']
|
data/examples/capped.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
require 'mongo'
|
3
3
|
|
4
4
|
include Mongo
|
@@ -10,9 +10,8 @@ puts "Connecting to #{host}:#{port}"
|
|
10
10
|
db = Connection.new(host, port).db('ruby-mongo-examples')
|
11
11
|
db.drop_collection('test')
|
12
12
|
|
13
|
-
# A capped collection has a max size and optionally a max number of records.
|
14
|
-
# Old records get pushed out by new ones once the size or max num records is
|
15
|
-
# reached.
|
13
|
+
# A capped collection has a max size and, optionally, a max number of records.
|
14
|
+
# Old records get pushed out by new ones once the size or max num records is reached.
|
16
15
|
coll = db.create_collection('test', :capped => true, :size => 1024, :max => 12)
|
17
16
|
|
18
17
|
100.times { |i| coll.insert('a' => i+1) }
|
data/examples/cursor.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
2
3
|
require 'mongo'
|
3
4
|
require 'pp'
|
4
5
|
|
@@ -12,7 +13,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
|
12
13
|
coll = db.collection('test')
|
13
14
|
|
14
15
|
# Erase all records from collection, if any
|
15
|
-
coll.
|
16
|
+
coll.remove
|
16
17
|
|
17
18
|
# Insert 3 records
|
18
19
|
3.times { |i| coll.insert({'a' => i+1}) }
|
@@ -23,7 +24,7 @@ coll.clear
|
|
23
24
|
# Find returns a Cursor, which is Enumerable. You can iterate:
|
24
25
|
coll.find().each { |row| pp row }
|
25
26
|
|
26
|
-
# You can turn it into an array
|
27
|
+
# You can turn it into an array:
|
27
28
|
array = coll.find().to_a
|
28
29
|
|
29
30
|
# You can iterate after turning it into an array (the cursor will iterate over
|
data/examples/gridfs.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
2
3
|
require 'mongo'
|
3
4
|
require 'mongo/gridfs'
|
4
5
|
|
@@ -19,7 +20,7 @@ end
|
|
19
20
|
GridStore.open(db, 'foobar', 'w') { |f| f.write("hello, world!") }
|
20
21
|
|
21
22
|
# Read it and print out the contents
|
22
|
-
dump(db, 'foobar')
|
23
|
+
dump(db, 'foobar')
|
23
24
|
|
24
25
|
# Append more data
|
25
26
|
GridStore.open(db, 'foobar', 'w+') { |f| f.write("\n"); f.puts "line two" }
|
data/examples/index_test.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
|
-
|
2
|
-
def errmsg
|
3
|
-
"%s: %s\n%s" % [self.class, message, (backtrace || []).join("\n") << "\n"]
|
4
|
-
end
|
5
|
-
end
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
2
|
|
7
|
-
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
8
3
|
require 'mongo'
|
9
4
|
|
10
5
|
include Mongo
|
@@ -15,6 +10,12 @@ port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
|
15
10
|
puts ">> Connecting to #{host}:#{port}"
|
16
11
|
db = Connection.new(host, port).db('ruby-mongo-index_test')
|
17
12
|
|
13
|
+
class Exception
|
14
|
+
def errmsg
|
15
|
+
"%s: %s\n%s" % [self.class, message, (backtrace || []).join("\n") << "\n"]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
18
19
|
puts ">> Dropping collection test"
|
19
20
|
begin
|
20
21
|
res = db.drop_collection('test')
|
@@ -43,8 +44,8 @@ coll.insert(arr)
|
|
43
44
|
puts "inserted"
|
44
45
|
|
45
46
|
puts ">> Creating index"
|
46
|
-
res = coll.create_index "all", :_id => 1, :number => 1, :rndm => 1, :msg => 1
|
47
|
-
|
47
|
+
#res = coll.create_index "all", :_id => 1, :number => 1, :rndm => 1, :msg => 1
|
48
|
+
res = coll.create_index [[:number, 1], [:rndm, 1], [:msg, 1]]
|
48
49
|
puts "created index: #{res.inspect}"
|
49
50
|
# ============================ Mongo Log ============================
|
50
51
|
# Fri Dec 5 14:45:02 Adding all existing records for ruby-mongo-console.test to new index
|
@@ -76,7 +77,7 @@ end
|
|
76
77
|
|
77
78
|
puts ">> Dropping index"
|
78
79
|
begin
|
79
|
-
res = coll.drop_index "
|
80
|
+
res = coll.drop_index "number_1_rndm_1_msg_1"
|
80
81
|
puts "dropped : #{res.inspect}"
|
81
82
|
rescue => e
|
82
83
|
puts "Error: #{e.errmsg}"
|
data/examples/info.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
2
3
|
require 'mongo'
|
3
4
|
|
4
5
|
include Mongo
|
@@ -11,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
|
11
12
|
coll = db.collection('test')
|
12
13
|
|
13
14
|
# Erase all records from collection, if any
|
14
|
-
coll.
|
15
|
+
coll.remove
|
15
16
|
|
16
17
|
# Insert 3 records
|
17
18
|
3.times { |i| coll.insert({'a' => i+1}) }
|
data/examples/queries.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
2
3
|
require 'mongo'
|
3
4
|
require 'pp'
|
4
5
|
|
@@ -12,7 +13,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
|
12
13
|
coll = db.collection('test')
|
13
14
|
|
14
15
|
# Remove all records, if any
|
15
|
-
coll.
|
16
|
+
coll.remove
|
16
17
|
|
17
18
|
# Insert three records
|
18
19
|
coll.insert('a' => 1)
|
data/examples/simple.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
2
3
|
require 'mongo'
|
3
4
|
|
4
5
|
include Mongo
|
@@ -11,7 +12,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
|
11
12
|
coll = db.collection('test')
|
12
13
|
|
13
14
|
# Erase all records from collection, if any
|
14
|
-
coll.
|
15
|
+
coll.remove
|
15
16
|
|
16
17
|
# Insert 3 records
|
17
18
|
3.times { |i| coll.insert({'a' => i+1}) }
|
data/examples/strict.rb
CHANGED
data/examples/types.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
2
3
|
require 'mongo'
|
3
4
|
require 'pp'
|
4
5
|
|
@@ -12,7 +13,7 @@ db = Connection.new(host, port).db('ruby-mongo-examples')
|
|
12
13
|
coll = db.collection('test')
|
13
14
|
|
14
15
|
# Remove all records, if any
|
15
|
-
coll.
|
16
|
+
coll.remove
|
16
17
|
|
17
18
|
# Insert record with all sorts of values
|
18
19
|
coll.insert('array' => [1, 2, 3],
|
@@ -32,4 +33,4 @@ coll.insert('array' => [1, 2, 3],
|
|
32
33
|
|
33
34
|
pp coll.find().next_document
|
34
35
|
|
35
|
-
coll.
|
36
|
+
coll.remove
|
data/lib/mongo.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
|
3
3
|
module Mongo
|
4
|
-
|
5
|
-
DESCENDING = -1
|
6
|
-
|
7
|
-
VERSION = "0.18.2"
|
4
|
+
VERSION = "0.18.3"
|
8
5
|
end
|
9
6
|
|
10
7
|
begin
|
@@ -13,32 +10,52 @@ begin
|
|
13
10
|
require 'mongo_ext/cbson'
|
14
11
|
raise LoadError unless defined?(CBson::VERSION) && CBson::VERSION == Mongo::VERSION
|
15
12
|
require 'mongo/util/bson_c'
|
16
|
-
BSON
|
13
|
+
BSON = BSON_C
|
17
14
|
rescue LoadError
|
18
15
|
require 'mongo/util/bson_ruby'
|
19
|
-
BSON
|
16
|
+
BSON = BSON_RUBY
|
20
17
|
warn "\n**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance."
|
21
18
|
warn " You can install the extension as follows:\n gem install mongo_ext\n"
|
22
19
|
warn " If you continue to receive this message after installing, make sure that the"
|
23
20
|
warn " mongo_ext gem is in your load path and that the mongo_ext and mongo gems are of the same version.\n"
|
24
21
|
end
|
25
22
|
|
23
|
+
module Mongo
|
24
|
+
ASCENDING = 1
|
25
|
+
DESCENDING = -1
|
26
|
+
|
27
|
+
module Constants
|
28
|
+
OP_REPLY = 1
|
29
|
+
OP_MSG = 1000
|
30
|
+
OP_UPDATE = 2001
|
31
|
+
OP_INSERT = 2002
|
32
|
+
OP_QUERY = 2004
|
33
|
+
OP_GET_MORE = 2005
|
34
|
+
OP_DELETE = 2006
|
35
|
+
OP_KILL_CURSORS = 2007
|
36
|
+
|
37
|
+
OP_QUERY_SLAVE_OK = 4
|
38
|
+
OP_QUERY_NO_CURSOR_TIMEOUT = 16
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
26
43
|
require 'mongo/types/binary'
|
27
44
|
require 'mongo/types/code'
|
28
45
|
require 'mongo/types/dbref'
|
29
46
|
require 'mongo/types/objectid'
|
30
47
|
require 'mongo/types/regexp_of_holding'
|
48
|
+
require 'mongo/types/min_max_keys'
|
31
49
|
|
32
50
|
require 'mongo/util/support'
|
33
51
|
require 'mongo/util/conversions'
|
34
52
|
require 'mongo/util/server_version'
|
35
53
|
require 'mongo/util/bson_ruby'
|
36
54
|
|
37
|
-
require 'mongo/
|
38
|
-
require 'mongo/
|
55
|
+
require 'mongo/admin'
|
56
|
+
require 'mongo/collection'
|
39
57
|
require 'mongo/connection'
|
40
|
-
require 'mongo/db'
|
41
58
|
require 'mongo/cursor'
|
42
|
-
require 'mongo/
|
43
|
-
require 'mongo/
|
44
|
-
|
59
|
+
require 'mongo/db'
|
60
|
+
require 'mongo/exceptions'
|
61
|
+
require 'mongo/gridfs'
|