MongoDB Ruby Driver Build Status Code Climate Coverage Status Gem Version

The officially supported Ruby driver for MongoDB.

Note: You are viewing the 2.x version of the MongoDB Ruby driver which is currently unreleased and under heavy development. To view the current stable version of driver, please use the 1.x-stable branch.

Installation

Gem Installation
The Ruby driver is released and distributed through RubyGems and it can be installed with the following command: bash gem install mongo Github Installation
For development and test environments (not recommended for production) you can also install the Ruby driver directly from source:

# clone the repository
git clone https://github.com/mongodb/mongo-ruby-driver.git
cd mongo-ruby-driver

# checkout a specific version by tag (optional)
git checkout 2.x.x

# install all development dependencies
gem install bundler
bundle install

# install the ruby driver
rake install

Usage

Here is a quick example of basic usage for the Ruby driver: ```ruby require 'mongo'

connecting to the database

client = Mongo::Client.new # defaults to localhost:27017 db = client['example-db'] coll = db['example-collection']

inserting documents

10.times { |i| coll.insert({ :count => i+1 }) }

finding documents

puts "There are #collcoll.count total documents. Here they are:" coll.find.each { |doc| puts doc.inspect }

updating documents

coll.update({ :count => 5 }, { :count => 'foobar' })

removing documents

coll.remove({ :count => 8 }) coll.remove ```

For many more usage examples and a full tutorial, please visit our wiki.
For API reference documentation, please visit here.

Compatibility

The MongoDB Ruby driver requires Ruby 1.8.7 or greater and is regularly tested against the platforms and environments listed below.

Ruby Platforms Operating Systems Architectures
MRI 1.9.3, 2.0.0, 2.1.0
JRuby 1.7.x
Rubinius 2.x
Windows
Linux
OS X
x86
x64
ARM

Support & Feedback

For issues, questions or feedback related to the Ruby driver, please look into our support channels. Please do not email any of the Ruby developers directly with issues or questions - you're more likely to get an answer quickly on the mongodb-user list on Google Groups.

Bugs & Feature Requests

Do you have a bug to report or a feature request to make?

  1. Visit our issue tracker and login (or create an account if necessary).
  2. Navigate to the RUBY project.
  3. Click 'Create Issue' and fill out all the applicable form fields.

When reporting an issue, please keep in mind that all information in JIRA for all driver projects (ex. RUBY, CSHARP, JAVA) and the Core Server (ex. SERVER) project is PUBLICLY visible.

PLEASE DO

  • Provide as much information as possible about the issue.
  • Provide detailed steps for reproducing the issue.
  • Provide any applicable code snippets, stack traces and log data.
  • Specify version information for the driver and MongoDB.

PLEASE DO NOT

  • Provide any sensitive data or server logs.
  • Report potential security issues publicly (see 'Security Issues').

Security Issues

If you’ve identified a potential security related issue in a driver or any other MongoDB project, please report it by following the instructions here.

Release History

Full release notes and release history are available here.

License

Copyright (C) 2009-2013 MongoDB, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.