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.
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.
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:https://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();
- This software is licensed under the MIT license
- The MongoDB Java driver is licensed under the Apache License
- The mongodb-rhino package is licensed under the Apache License
A slightly modified version of the Sergi's narwhal-mongodb's test suite has been included in this project.