Created
November 27, 2017 18:16
-
-
Save emrivero/5473331a5325f4fe1c3669609dd2a763 to your computer and use it in GitHub Desktop.
Quickstart Mongodb connect in nodejs
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
const MongoClient = require('mongodb').MongoClient; | |
const assert = require('assert'); | |
const url = 'mongodb://localhost:27017/myproject'; | |
MongoClient.connect(url, function(err, db) { | |
assert.equal(null, err); | |
console.log("Connected successfully to server"); | |
//.. code here | |
//.. | |
db.close(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment