-
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.
Merge pull request #256 from mafintosh/saintedlama/mongodb-native
Use mongodb-native instead of mongodb-core driver
- Loading branch information
Showing
30 changed files
with
482 additions
and
331 deletions.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
.DS_Store | ||
coverage/ | ||
*.*~ |
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 |
---|---|---|
|
@@ -31,14 +31,17 @@ var db = mongojs('example.com/mydb', ['mycollection']) | |
var db = mongojs('username:[email protected]/mydb', ['mycollection']) | ||
|
||
// connect using SCRAM-SHA-1 mechanism | ||
var db = mongojs('username:[email protected]/mydb', ['mycollection'], {authMechanism: 'ScramSHA1'}) | ||
var db = mongojs('username:[email protected]/mydb?authMechanism=SCRAM-SHA-1', ['mycollection']) | ||
|
||
// connect using a different auth source | ||
var db = mongojs('username:[email protected]/mydb?authSource=authdb', ['mycollection']) | ||
|
||
// connect now, and worry about collections later | ||
var db = mongojs('mydb') | ||
var mycollection = db.collection('mycollection') | ||
``` | ||
|
||
__Attention MongoDB 3 users:__ In MongoDB 3 the default auth mechanism is ScramSHA1 not MongoCR (the default auth mechanism in mongojs). When connecting to an auth enabled MongoDB 3 instance providing the authMechanism option value 'ScramSHA1' is mandatory! | ||
[More connection string examples](http://mongodb.github.io/node-mongodb-native/2.0/reference/connecting/authenticating/) | ||
|
||
After we connected we can query or update the database just how we would using the mongo API with the exception that we use a callback. | ||
The format for callbacks is always `callback(error, value)` where error is null if no exception has occured. The update methods `save`, `remove`, `update` and `findAndModify` also pass the `lastErrorObject` as the last argument to the callback function. | ||
|
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.