Purpose : How to create new Collection.

collection_create.js

mongo=new Mongo(“localhost”);
newDB=mongo.getDB(“newDB”);
collections=newDB.getCollectionNames();
print(“Initial Collections: “);
printjson(collections);
newDB.createCollection(“newCollectionA”);
newDB.createCollection(“newCollectionB”);
print(“After Collection Creation:”);
collections=newDB.getCollectionNames();
printjson(collections);

ice_screenshot_20151210-141926

Advertisements