Display all collections in Mongo DB except for a specific one

Is there a way in MongoDB to retrieve all documents except for one named Test?

The current code retrieves all the documents.

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

Answer №1

The accurate solution is:

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Populating an array during an event and then utilizing it outside of the event function handler

I have a challenge where I need to populate an array with values from various buttons whenever they are clicked. The goal is to then access this array outside of the event handler function. Although I have attempted a solution, I am struggling to access th ...

Display information associated with a specific identifier in a single row using PHP Laravel

I am looking to display all four types of divisions (marriage, birth/death, acting marriage, acting birth/death) related to the same person in a single row. Below is the structure of my database tables Registrar Table- registrar id | name 1 | ...

Executing a SQL query with multiple WHERE clauses by assigning values in one command

Here is an example of a values array: const params = [ ['2022-12-10', 'aaaaa', '2022-12-01', 'xhxha', '2022-12-10'], ['2022-12-11', 'ababa', '2022-12-01', 'xhxha', &a ...

Modules are being installed to the application's root directory using NPM

I made a mistake and have tried everything to correct it, but no success. Every time I run 'npm install' on a new node project, it installs all dependencies in the root of the application instead of the expected /node_modules/ directory. For ex ...

After a single click, the functionality of jquery.nav.js seems to be malfunctioning

Encountering an error message: Uncaught TypeError: Cannot read property 'top' of undefined(…) jquery.nav.js:183 In an effort to convert my web app into a Single Page Application (SPA) using the jquery.nav.js library (available at https://githu ...

Using FormData to Upload Files

My challenge involves uploading a file to a Node backend that utilizes Multer for handling file uploads. Multer has specific requirements for form submission to ensure that the request.file parameter is not undefined. Despite this, I have managed to come u ...

Troubleshooting problem with Angular's ng-repeat directive in dealing with varying number of child objects

I am currently dealing with tree-structured data where the parent nodes can have an indefinite number of children, and those children can also have an indefinite number of children, creating a deeply nested structure. While I have successfully formatted th ...

What is preventing me from adding a borderRadius to this particular React bootstrap tab?

I have been working on tabbed content and encountered an issue with applying border radius. Despite adding style={{borderRadius: "10px"}}, it seems to have no effect. This styling works perfectly everywhere else in my project, so I am puzzled as ...

Having issues with importing momentjs by reference in TypeScript with amd configuration

I'm puzzled by the difference in behavior between these two snippets: import * as moment from "../Typings/moment"; One works, while this one doesn't: /// <reference path="../Typings/moment.d.ts" /> import * as moment from "moment"; It t ...

Is it possible to alter the video dynamically according to the state in Vuex?

I am working on a small web application that mimics the appearance of FaceTime. My goal is to switch between video elements by clicking a "Next" button, which will update a value in Vuex and swap out the video accordingly. I initially attempted this appr ...

Setting a default value in an arrow function

Currently, I am working on a section of code that renders a simple loading bar. const smallSpinner = document.getElementById('spinner-small').getContext('2d'); let pointToFill = 4.72; let cw = smallSpinner.canvas.width; //Returns canva ...

Error alert: Conversion issue encountered when trying to output a singular variable as a string from

Encountered a peculiar error while attempting to display a single variable retrieved from the database. The process involves querying the top ID from the database and storing it in a variable. The code snippet looks like this: $ID_Query = "SELECT DIS ...

Using the prop callback in a React test renderer does not trigger updates in hooks

I am currently exploring ways to effectively test a React function component that utilizes hooks for state management. The issue I am encountering revolves around the onChange prop function not properly updating the state value of my useState hook. This in ...

Encounter a Config validation error while trying to utilize Nest.js ConfigService within e2e tests

I'm encountering an error despite having the NODE_ENV=development variable in my .env file. The error message reads: ● Test suite failed to run Config validation error: "NODE_ENV" must be one of [development, production] 11 | imports ...

Python for loop used to update a dictionary

Seeking guidance: I attempted to update a dictionary within a for loop, but encountered an issue where only the first item is successfully added while the rest are lost. As someone relatively new to this, I would appreciate any advice on what might be in ...

Filter a Vue table by column name with specific conditions

I am working on code that filters a table based on user input. The process involves selecting a column from a drop-down menu, choosing an operator from another drop-down menu, and entering a search value. I want to filter the table based on these criteria. ...

Managing numerous requests from clients to a PHP page connected to a MySQL database

On my Ubuntu server, I have a mobile app that sends JSON requests to a PHP page which connects to a MySQL database. However, I've noticed that sometimes when there are a lot of requests coming in at the same time, some requests get dropped. I'm l ...

What is the best method for combining four different tables in SQL with specified conditions?

Task: Construct an SQL query to fetch data from multiple tables based on certain conditions. The database consists of four tables: orders +------+------------+------------+ | id | date_added | currency | +------+------------+------------+ | 1 | 2 ...

Pressing the Enter key does not initiate a redirect on the page

Hey there! I've set up a text field where users need to input a password in order to download a PDF file. If the password is correct, they are directed to the URL of the PDF file. However, if the password is wrong, they are redirected to a page called ...

What are the steps to testing an endpoint with Jasmine/Karma?

Within one of my components, there is a method that makes a call to an endpoint in the following manner... private async getRolesAsync(): Promise<void> { const roles = await this.http.get<any>('https://sample-endpoint.com').toProm ...