-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,13 @@ It is available through npm: | |
|
||
DB is very simple to use: | ||
|
||
``` js | ||
var db = require('db').connect(databaseURL, [collections]); | ||
``` | ||
|
||
Some examples of this could be: | ||
|
||
``` js | ||
// simple usage for a local db | ||
var db = require('db').connect('mydb', ['mycollection']); | ||
|
||
|
@@ -18,9 +21,11 @@ Some examples of this could be: | |
|
||
// we can also provide some credentials | ||
var db = require('db').connect('username:[email protected]/mydb', ['mycollection']); | ||
``` | ||
|
||
After we connected to can query or update the database just how we would using the mongo shell with the exception that we use a callback | ||
|
||
``` js | ||
// find everything | ||
db.mycollection.find(callback); | ||
|
||
|
@@ -35,5 +40,6 @@ After we connected to can query or update the database just how we would using t | |
|
||
// use the save function to just save a document (the callback is optional for all writes) | ||
db.mycollection.save({created:'just now'}); | ||
|
||
``` | ||
|
||
For more detailed information about the different usages of update and quering see [the mongo docs](http://www.mongodb.org/display/DOCS/Manual) |