Skip to content

Instantly share code, notes, and snippets.

@mpj
Created November 23, 2011 22:00
Show Gist options
  • Save mpj/1390054 to your computer and use it in GitHub Desktop.
Save mpj/1390054 to your computer and use it in GitHub Desktop.
Calling mongodb in node
var Db = require('mongodb').Db;
var Connection = require('mongodb').Connection;
var Server = require('mongodb').Server;
var BSON = require('mongodb').BSON;
var ObjectID = require('mongodb').ObjectID;
exports.index = function(req, res) {
this.db = new Db('node-hipchat-logger',
new Server('localhost', 27017, {auto_reconnect: true}, {}));
this.db.open(function(){});
this.db.collection('logs', function(err, coll) {
coll.insert( { lol: 1 }, function(err, document) {
console.log(document);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment