Mongo DB access layer compatible with the dbstream API
var db = require( "dbstream-mongo" );
var connection = db.connect( "mongodb://127.0.0.1:27017/test", { collection: "test" } );
// write or update
var cursor = new connection.Cursor()
cursor.write({ id: 1, name: "Hello" });
cursor.write({ id: 2, name: "World" });
cursor.on("finish", function() {
console.log("Saved 2 objects");
});
cursor.end();
// read
new connection.Cursor()
.find({ id: 2 })
.limit( 1 )
.on("data", function (obj) {
console.log("Loaded", obj);
});
This module implements the dbstream API. For the complete documention see: https://github.com/avinoamr/dbstream
url
a mongodb connection url stringoptions
standard mongodb connection options, plus acollection
name key- Returns a dbstream Connection object
Creates a MongoDB connection. Uses the MongoClient.connect arguments.