Compass Filter in MongoDB

Shraddha Paghdar Nov 08, 2022
Compass Filter in MongoDB

This short article will look at many methods to use a compass filter in MongoDB.

Compass Filter in MongoDB

MongoDB has a GUI called Compass. It also goes by the name MongoDB GUI.

Users can examine the contents of their stored data using MongoDB even if they are unfamiliar with its query syntax. Using the Compass GUI, we can manage indexes, execute document validation, and optimize speed as we explore our data in a visual interface.

MongoDB Compass will reduce the list of documents to the few entries that fit the filtering criterion. To filter data in the FILTER column, you can use any legitimate query document that you would use in the find() operation.

If you make a syntactic mistake, Compass will indicate a query issue by turning the FILTER badge red.

compass overview

  • Mongo Shell Option Syntax:

    db.employees.find({ "country": "United Kindgdom" })
    
  • Compass Filter Option Syntax:

    Paste the following syntax into the filter tab after opening the collection. To run the search and see the revised results, click Find.

    compass filter

    { "country": "United Kindgdom" }
    

    Compass frees you from the hassle of keeping track of the names of complex databases or collections, allowing you to quickly browse any database or collection on your MongoDB server. You can click RESET to remove the filter documents you’ve applied.

The MongoDB Extended JSON BSON data formats are supported by the Compass Filter when used in mongo shell mode. To access the nested object, you can filter using the below example:

{ "address.country": "United Kindgdom" }

Here, the word address refers to an object that includes the words country and United Kingdom as key and value, along with additional key-value pairs like zip code and city.

Shraddha Paghdar avatar Shraddha Paghdar avatar

Shraddha is a JavaScript nerd that utilises it for everything from experimenting to assisting individuals and businesses with day-to-day operations and business growth. She is a writer, chef, and computer programmer. As a senior MEAN/MERN stack developer and project manager with more than 4 years of experience in this sector, she now handles multiple projects. She has been producing technical writing for at least a year and a half. She enjoys coming up with fresh, innovative ideas.

LinkedIn