Created
August 20, 2018 11:21
-
-
Save annibuliful/c41a3578d94ea9638dabac6eca3be8cc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 url = "mongodb://localhost:27017/"; | |
MongoClient.connect(url, {useNewUrlParser: true}, function (err, db) { | |
if (err) throw err; | |
const dbo = db.db("mydb"); | |
//Create a collection name "customers": | |
dbo.createCollection("customers", function (err, res) { | |
if (err) throw err; | |
console.log("Collection created!"); | |
db.close(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment