var db = db.getSiblingDB('omdb'); // Delete all collections + all records db.messages.deleteMany({}); db.tags.deleteMany({}); db.users.deleteMany({}); db.sessions.deleteMany({}); // Insert data in collections load('mong_msg.js'); load('mong_tag.js'); load('mong_usr.js'); // Print all collections + records count var collections = db.getCollectionNames(); print('Collections inside the db:'); for(var i = 0; i < collections.length; i++){ var name = collections[i]; if(name.substr(0, 6) != 'system') print(name + ' - ' + db[name].count() + ' records'); }