0.3.0 • Published 11 years ago

mongo-helper v0.3.0

Weekly downloads
10
License
-
Repository
github
Last release
11 years ago

Mongo Helper

This is a simple wrapper created to make it easier for us to prototype systems quickly with minimal errors. My priority here is to keep things simple, rather than giving the user a lot of options.

NOTE: Don't use this if you don't already know how to interact with MongoDB. Using Mongo Helper is no excuse for not understanding the underlying code.

Installing

THIS IS NOT IN NPM YET. DISREGARD THE FOLLOWING.

You can either install it by adding the following dependency in package.json:

"dependencies": {
  "mongoHelper": "*" //Using * for versioning isn't recommended.  I'll fix that in the future.
}

and then running npm install or by running npm install mongoHelper.

YOU MAY CEASE YOUR DISREGARDING NOW.

Usage

Now that you've installed mongoHelper, how can you use it?

First, navigate to node_modules/mongoHelper and open up config.js. This is initalized with some defaut settings, but you probably want to alter them to meet your needs. Then, require the mongoHelper object with:

var mongoHelper = require('mongoHelper');

Currently, only insert and find are implemented.

####Insert Insert takes three parameters: coll, query, and next.

  • coll is a string representing the collection we want to insert query into
  • query is the object to be inserted into the collection
  • next is a function that will be called after the db operations finish. The database is closed before next is called, so you can call another db operation with next.

For example, if I wanted to insert {foo: 'bar'} into the foobar collection (and had required it like above, I would write:

mongoHelper.insert('foobar', {foo: 'bar'});

If I then wanted to run myFunc after that:

mongoHelper.insert('foobar', {foo: 'bar'}, myfunc);

####Find Like insert, find takes three parameters. The one change is that the results of the find statement will be passed to the function you input.

####Remove The data removed is passed to next.

0.3.0

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago