Skip to content

Instantly share code, notes, and snippets.

@ddmills
Created January 20, 2016 02:10
Show Gist options
  • Save ddmills/c60919e356c66ba80837 to your computer and use it in GitHub Desktop.
Save ddmills/c60919e356c66ba80837 to your computer and use it in GitHub Desktop.
/*
* NodeJS driver for MongoDB
*
* This is from the https://docs.mongodb.org/getting-started/node/client/ documentation.
* Expects database on mongodb://localhost:27017/test
*/
var MongoClient = require('mongodb').MongoClient;
var assert = require('assert');
var url = 'mongodb://localhost:27017/test';
MongoClient.connect(url, function(err, db) {
assert.equal(null, err);
console.log("Connected correctly to server.");
db.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment