Skip to content

Instantly share code, notes, and snippets.

@annibuliful
Created August 20, 2018 11:21
Show Gist options
  • Save annibuliful/c41a3578d94ea9638dabac6eca3be8cc to your computer and use it in GitHub Desktop.
Save annibuliful/c41a3578d94ea9638dabac6eca3be8cc to your computer and use it in GitHub Desktop.
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