javascriptmysqlmongodbnosqlrobo3t

Mongo DB show all collections except one


in Mongo DB how can I retrieve all documents except one which is Test

my code shows all the documents

db.getCollectionNames().forEach(function(collection) { 
    var result = db[collection]; 
    if(result != 'Test') { 
        print("All the documents: " + " for collection: "+ collection);
    } 
});

Solution

  • The correct is:

      db.getCollectionNames().forEach(function(collection){
         if(collection != 'Test') {
             print("All the documents: " + " for collection: "+ collection);
            }
           }
          );