In Mongobooster we can create our own Database, Collections(tables), Document(Tuple/Row) directly or we can create them using Node.js.
//to import mongodb
var MongoClient = require('mongodb').MongoClient;
//mydb is the new database we want to create
var url = "mongodb://localhost:27017/mydb";
//make client connect
MongoClient.connect(url, function (err, client) {
var db = client.db('mydb');
if (err) throw err;
//customers is a collection we want to create
db.createCollection("customers", function (err, result) {
if (err) throw err;
console.log("database and Collection created!");
client.close();
});
});
Write this code in your editor and save with js extension and run this at your terminal.
(I have saved above code with createdb.js)
Run Command
C:\Users\Your Name>node createdb.js
You can see the “database and Collection created!” message at console log.
Result
database and Collection created!
That means your database has been created. To see this database you need to open mongobooster and refresh your localhost.
Here, we have created collection ‘customer’ also here to see this database ‘mydb’ in our mongobooster tool. If you do not create Collection here then the Database will be created but it will not show at your mongobooster tool.
Learn More