0.0.3 • Published 9 years ago

crudlet-mongodb v0.0.3

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

Build Status Coverage Status Dependency Status

Streamable Mongodb library. Works well with crudlet.

installation

npm install crudlet-mongodb
var crudlet = require("crudlet");
var mongodb = require("crudlet-mongodb");

var db = mongodb("mongodb://localhost:27017/crudlet-test");
db(crudlet.op("insert", { data: { name: "blarg"}})).on("data", function() {

});

// streaming operations
crudlet.
open(db).
write(crudlet.op("insert", { data: { name: "abba"}})).
end(crudlet.op("remove", { query: { name: "abba"}}));


// load the entire collection
var stream = db(crudlet.op("load", { multi: true }));

stream.on("data", function() {
  // handle cursor data
});

stream.on("end", function() {
  // end load
});

// pause the mongodb cursor
stream.pause();

db mongodb(host)

creates a local crudelt database

  • options - options for the local db
    • name - name of db (optional)
    • store - store to use

runs an operation

  • operation - operation to run can be: insert, remove, update, or load
  • options - operation specific options

insert options:

  • data - data to insert. Can be an object, or an array to insert multiple

remove options:

  • query - mongodb search query
  • multi - TRUE if you want to remove multiple items (false by default)

update options:

  • query - mongodb search query
  • multi - TRUE if you want to update multiple items (false by default)
  • data - data to set - this is merged with existing data

load options:

  • query - mongodb search query
  • multi - TRUE if you want to load multiple items (one by default)