2008-12-02 01:20:00 +00:00
|
|
|
= Introduction
|
|
|
|
|
2009-01-07 21:07:22 +00:00
|
|
|
This is a Ruby driver for the 10gen Mongo DB. For more information about
|
|
|
|
Mongo, see http://www.mongodb.org.
|
2008-12-02 01:20:00 +00:00
|
|
|
|
2009-01-07 21:07:22 +00:00
|
|
|
Note: this driver is still alpha quality. The API will change, as *may* the
|
|
|
|
data saved to the database (especially primary key values). Do *_not_* use
|
|
|
|
this for any production data yet.
|
2008-12-04 21:38:04 +00:00
|
|
|
|
2009-01-08 16:48:59 +00:00
|
|
|
Start by reading the XGen::Mongo::Driver::Mongo and XGen::Mongo::Driver::DB
|
|
|
|
documentation, then move on to XGen::Mongo::Driver::Collection and
|
|
|
|
XGen::Mongo::Driver::Cursor.
|
|
|
|
|
|
|
|
A quick code sample:
|
|
|
|
|
|
|
|
require 'mongo'
|
|
|
|
|
|
|
|
include XGen::Mongo::Driver
|
|
|
|
|
|
|
|
db = Mongo.new('localhost').db('sample-db')
|
|
|
|
coll = db.collection('test')
|
|
|
|
|
|
|
|
coll.clear
|
|
|
|
3.times { |i| coll.insert({'a' => i+1}) }
|
|
|
|
puts "There are #{coll.count()} records. Here they are:"
|
|
|
|
coll.find().each { |doc| puts doc.inspect }
|
2008-12-02 01:21:22 +00:00
|
|
|
|
2009-01-08 16:42:52 +00:00
|
|
|
= Installation
|
|
|
|
|
|
|
|
Install the "mongo" gem by typing
|
|
|
|
|
|
|
|
$ sudo gem install mongo
|
|
|
|
|
|
|
|
The source code is available at http://github.com/jimm/mongo-ruby-driver. You
|
|
|
|
can either clone the git repository or download a tarball or zip file. Once
|
|
|
|
you have the source, you can use it from wherever you downloaded it or you can
|
|
|
|
install it as a gem from the source by typing
|
|
|
|
|
|
|
|
$ rake gem:install
|
|
|
|
|
|
|
|
|
2008-12-02 01:20:00 +00:00
|
|
|
= Demo
|
|
|
|
|
2009-01-08 16:42:52 +00:00
|
|
|
You can see and run the examples if you've downloaded the source. Mongo must
|
|
|
|
be running, of course.
|
2009-01-07 21:07:22 +00:00
|
|
|
|
2008-12-17 16:43:08 +00:00
|
|
|
$ ruby examples/simple.rb
|
2008-12-02 01:20:00 +00:00
|
|
|
|
2009-01-08 16:42:52 +00:00
|
|
|
See also the test code, especially tests/test_db_api.rb.
|
2008-12-02 01:20:00 +00:00
|
|
|
|
2008-12-02 01:21:22 +00:00
|
|
|
|
2008-12-02 01:20:00 +00:00
|
|
|
= Testing
|
|
|
|
|
2009-01-08 16:42:52 +00:00
|
|
|
If you have the source code, you can run the tests.
|
|
|
|
|
2008-12-02 01:20:00 +00:00
|
|
|
$ rake test
|
|
|
|
|
|
|
|
The tests assume that the Mongo database is running on the default port.
|
|
|
|
|
2009-01-12 14:48:24 +00:00
|
|
|
The project mongo-qa (http://github.com/mongodb/mongo-qa) contains many more
|
|
|
|
Mongo driver tests that are language independent. To run thoses tests as part
|
|
|
|
of the "rake test" task, run
|
|
|
|
|
|
|
|
$ rake mongo_qa
|
|
|
|
$ rake test
|
|
|
|
|
|
|
|
The mongo_qa task uses the "git clone" command to make a copy of that project
|
|
|
|
in a directory named mongo-qa. If the directory already exists, then the
|
|
|
|
mongo_qa task uses "git pull" to updated the code that's there. The Ruby
|
|
|
|
driver tests will then use some of the data files from that project when it
|
|
|
|
runs BSON tests. You can delete this directory at any time if you don't want
|
|
|
|
to run those tests any more.
|
|
|
|
|
2009-01-12 16:23:07 +00:00
|
|
|
Additionally, the script bin/validate is used by the mongo-qa project's
|
|
|
|
validator script.
|
|
|
|
|
2008-12-02 01:21:22 +00:00
|
|
|
|
2008-12-04 22:02:19 +00:00
|
|
|
= Documentation
|
|
|
|
|
2009-01-08 16:42:52 +00:00
|
|
|
This documentation is available online at http://mongo.rubyforge.org. You can
|
|
|
|
generate the documentation if you have the source by typing
|
|
|
|
|
2008-12-04 22:02:19 +00:00
|
|
|
$ rake rdoc
|
|
|
|
|
2009-01-08 16:42:52 +00:00
|
|
|
Then open the file html/index.html.
|
2008-12-02 15:45:02 +00:00
|
|
|
|
|
|
|
|
2009-01-07 21:07:22 +00:00
|
|
|
= Release Notes
|
2008-12-02 15:45:02 +00:00
|
|
|
|
2009-01-07 17:51:16 +00:00
|
|
|
See the git log comments.
|
2008-12-02 15:45:02 +00:00
|
|
|
|
|
|
|
|
2008-12-02 01:21:22 +00:00
|
|
|
= To Do
|
|
|
|
|
2009-01-07 21:56:34 +00:00
|
|
|
* Add group_by. Need to figure out how we are going to send functions. The
|
|
|
|
current thinking is that Mongo will allow a subset of JavaScript (which we
|
|
|
|
would have to send as a string), but this is still under discussion.
|
|
|
|
|
2009-01-07 21:27:49 +00:00
|
|
|
* Add explain and hint support.
|
|
|
|
|
2009-01-07 14:46:30 +00:00
|
|
|
* Only update message sizes once, not after every write of a value. This will
|
|
|
|
require an explicit call to update_message_length in each message subclass.
|
|
|
|
|
2008-12-17 16:03:09 +00:00
|
|
|
* Tests for update and repsert.
|
|
|
|
|
2008-12-16 22:35:31 +00:00
|
|
|
* Add a way to specify a collection of databases on startup (a simple array of
|
|
|
|
IP address/port numbers, perhaps, or a hash or something). The driver would
|
2008-12-16 22:19:53 +00:00
|
|
|
then find the master and, on each subsequent command, ask that machine if it
|
|
|
|
is the master before proceeding.
|
2008-12-16 22:08:15 +00:00
|
|
|
|
2008-12-09 18:00:14 +00:00
|
|
|
* Tests that prove that this driver's ObjectID and Geir's Java version do the
|
2008-12-16 12:42:56 +00:00
|
|
|
same thing. (I've done so manually.)
|
2008-12-09 18:00:14 +00:00
|
|
|
|
2008-12-08 20:57:20 +00:00
|
|
|
* Support more types: REF, SYMBOL, CODE_W_SCOPE, etc.
|
2008-12-04 21:25:51 +00:00
|
|
|
|
|
|
|
* Introduce optional per-database and per-collection PKInjector.
|
|
|
|
|
2008-12-02 01:21:22 +00:00
|
|
|
* More tests.
|
|
|
|
|
2008-12-08 20:57:20 +00:00
|
|
|
* Study src/main/ed/db/{dbcollection,dbcursor,db}.js and ByteEncoder.java in
|
|
|
|
the Babble code. That's what I should be writing to.
|
2008-12-02 12:22:32 +00:00
|
|
|
|
2008-12-02 01:21:22 +00:00
|
|
|
|
2008-12-05 21:39:00 +00:00
|
|
|
= Credits
|
|
|
|
|
|
|
|
Adrian Madrid, aemadrid@gmail.com
|
2009-01-06 15:49:18 +00:00
|
|
|
* bin/mongo_console
|
2008-12-05 21:39:00 +00:00
|
|
|
* examples/benchmarks.rb
|
|
|
|
* examples/irb.rb
|
2008-12-08 20:08:14 +00:00
|
|
|
* Modifications to examples/simple.rb
|
|
|
|
* Found plenty of bugs and missing features.
|
2009-01-06 15:49:18 +00:00
|
|
|
* Ruby 1.9 support.
|
|
|
|
* Gem support.
|
2008-12-08 20:08:14 +00:00
|
|
|
* Many other code suggestions and improvements.
|
2008-12-05 21:39:00 +00:00
|
|
|
|
|
|
|
|
2008-12-02 01:20:00 +00:00
|
|
|
= License
|
|
|
|
|
2009-01-06 15:51:01 +00:00
|
|
|
Copyright (C) 2008-2009 10gen Inc.
|
2008-12-02 01:20:00 +00:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Affero General Public License, version 3, as published by
|
|
|
|
the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
details.
|
|
|
|
|
2008-12-17 16:49:06 +00:00
|
|
|
See http://www.gnu.org/licenses for a copy of the GNU Affero General Public
|
2008-12-02 01:20:00 +00:00
|
|
|
License.
|