Jul 16

MongoDb Examples – 2 : Schema Initialization

Create a Mongo Script and Populate with some data:



nano init.mongo.js  (in Linux or MacOs)


Put content in the script file:


db = new Mongo().getDB('issuetracker');
     status: 'Open', owner: 'Ravan',     
     created: new Date('2016-08-15'), effort: 5,
     completionDate: undefined,
     title: 'Error in console when clicking Add',
     status: 'Assigned', owner: 'Eddie',
     created: new Date('2016-08-16'), 
     effort: 14,
     completionDate: new Date('2016-08-30'),
     title: 'Missing bottom border on panel',

db.issues.createIndex({ status: 1 });
db.issues.createIndex({ owner: 1 });
db.issues.createIndex({ created: 1 });


Run the script:

mongo init.mongo.js


Skip to toolbar