demo_create_mongo_table.js:
var MongoClient = require('mongodb').MongoClient; var url = "mongodb://localhost:27017/mydb"; MongoClient.connect(url, function(err, db) { if (err) throw err; db.createCollection("customers", function(err, res) { if (err) throw err; console.log("Table created!"); db.close(); }); });
C:\Users\My Name>node demo_create_mongo_table.js
Table created!