forked from nex3/marmalade
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example of connecting to mongo from node
- Loading branch information
1 parent
fc4f3d0
commit 5f03a67
Showing
1 changed file
with
34 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
This documents some of the user db and just some straight forward | ||
node/mongo nonsense I keep forgetting. | ||
To make this work with npm and shit on a running marmalade vm: | ||
PATH=$NODEROOT/bin:$PATH | ||
cd ~/.node_modules/marmalade | ||
node | ||
*/ | ||
|
||
// specify a username to find | ||
var username_to_find = "someuser"; | ||
var mongo = require("mongodb"); | ||
var server=new mongo.Server("localhost", m.Connection.DEFAULT_PORT, {}); | ||
var mdb = new m.Db("marmalade", ms).open( | ||
function (err, db) { | ||
db.collection( | ||
"users", | ||
function (err, users_col) { | ||
colusers.findOne( | ||
{ "name": username_to_find }, | ||
function (err, user) { | ||
console.log(user.digest); | ||
} | ||
); | ||
} | ||
) | ||
} | ||
); | ||
|
||
/* Ends */ |