Home

Awesome

MongoDB driver for Ringo.js

ringo-mongodb is a CommonJS-compliant wrapper around the official MongoDB Java driver.

Mongodb's Extended JSON format support is provided by mongodb-rhino which is also included in this project.

Installation

ringo-admin install amigrave/ringo-mongodb

WARNING: This is a work in progress. This module will be available on ringo packages as soon as the api is stable.

Examples

var mongo = require('ringo-mongodb');
var client = new mongo.MongoClient('localhost', 27017);
var db = client.getDB('test_database');
db.getCollectionNames().forEach(function(dbname) {
    console.log(dbname);
});
// You can easily connect to a given database using a connect URI
var db = require('ringo-mongodb').connect('mongodb://localhost/test_database');

db.getCollectionNames();
// []

var col = db.getCollection('myCollection');
col.count();
// 0

var doc = {
   greet : "Hello"
   name : "World",
};
col.insert(doc);
col.count();
// 1

var myDoc = col.findOne();
myDoc.id
//'517c2ef83004306ea66a08f2'

Object.keys(myDoc.data)
// [ '_id', 'greet', 'name' ]

>> db.getCollectionNames();
[ 'myCollection', 'system.indexes' ]

col.drop();

Documentation

Browse the API

License

Note

A slightly modified version of the Sergi's narwhal-mongodb's test suite has been included in this project.