Skip to content

Commit

Permalink
example of connecting to mongo from node
Browse files Browse the repository at this point in the history
  • Loading branch information
nicferrier committed Feb 5, 2014
1 parent fc4f3d0 commit 5f03a67
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions admin/example.js
@@ -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 */

0 comments on commit 5f03a67

Please sign in to comment.