demo_create_mongo_db.js:
var MongoClient = require('mongodb').MongoClient; //Create a database named "mydb": var url = "mongodb://localhost:27017/mydb"; MongoClient.connect(url, function(err, db) { if (err) throw err; console.log("Database created!"); db.close(); });
C:\Users\My Name>node demo_create_mongo_db.js
Database created!