<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: VisuaLeaf</title>
    <description>The latest articles on Forem by VisuaLeaf (@visualeaf).</description>
    <link>https://forem.com/visualeaf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3818324%2F6cb54fe1-a36c-4f1a-a7b5-fa360f5daf8a.png</url>
      <title>Forem: VisuaLeaf</title>
      <link>https://forem.com/visualeaf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/visualeaf"/>
    <language>en</language>
    <item>
      <title>MongoDB vs PostgreSQL: Why the Same Data Looks So Different</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Tue, 26 May 2026 13:02:27 +0000</pubDate>
      <link>https://forem.com/visualeaf/mongodb-vs-postgresql-why-the-same-data-looks-so-different-9k0</link>
      <guid>https://forem.com/visualeaf/mongodb-vs-postgresql-why-the-same-data-looks-so-different-9k0</guid>
      <description>&lt;p&gt;When deciding between MongoDB and PostgreSQL, the biggest difference is how the data is organized.&lt;/p&gt;

&lt;p&gt;PostgreSQL is a strong choice when the data is structured and works well in related tables. MongoDB is often more suitable when the data is flexible, nested, or expected to evolve.&lt;/p&gt;

&lt;p&gt;Both databases are great, but they approach the same data in different ways.&lt;/p&gt;

&lt;p&gt;To make that easier to understand, the same clinic data is shown below in two forms: once as MongoDB documents and once as PostgreSQL tables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxxydhm6zlolz3shbozi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxxydhm6zlolz3shbozi.png" alt="MongoDB document model compared with PostgreSQL relational schema for clinic data" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The same clinic data was modeled as a MongoDB document and a PostgreSQL relational schema.&lt;/p&gt;

&lt;p&gt;What Makes Them Different: Tables vs Documents&lt;/p&gt;

&lt;p&gt;This picture illustrates how the same data about ''&lt;strong&gt;clinic visits&lt;/strong&gt;'' looks in two database systems. In MongoDB, the information about visits is combined within one document, whereas PostgreSQL stores the data in separate tables.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Diagram Detail&lt;/th&gt;
&lt;th&gt;MongoDB&lt;/th&gt;
&lt;th&gt;PostgreSQL&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Structure&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Single &lt;code&gt;visits&lt;/code&gt; collection&lt;/td&gt;
&lt;td&gt;Multiple tables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;How the data is organized&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Patient, doctor, symptoms, prescriptions, and invoice are all included in &lt;strong&gt;one document&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Patients, doctors, appointments, prescriptions, and invoices are stored in &lt;strong&gt;separate tables&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best for&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Data that is usually read together&lt;/td&gt;
&lt;td&gt;Data with strong relationships&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Example from the diagram&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;One clinic visit contains nested details&lt;/td&gt;
&lt;td&gt;One appointment connects to a patient, doctor, prescriptions, and invoice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Main advantage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;It's easier to read a whole clinic visit in one place&lt;/td&gt;
&lt;td&gt;Relationships are clear and protected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;What to be careful about&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Documents can become inconsistent or too large without good design&lt;/td&gt;
&lt;td&gt;Queries often need joins to bring related data together&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That is the basic distinction between the two databases.&lt;/p&gt;

&lt;p&gt;In MongoDB, we start with the document.&lt;br&gt;&lt;br&gt;
In PostgreSQL, we start with the relationships.&lt;/p&gt;

&lt;p&gt;Both database models can represent the same clinic system, but the way you look at your data changes significantly.&lt;/p&gt;
&lt;h2&gt;
  
  
  SQL vs NoSQL Schema Design: Structure First vs Data First
&lt;/h2&gt;

&lt;p&gt;Another big difference is how the structure is created.&lt;/p&gt;

&lt;p&gt;In PostgreSQL, you first create the table. Then you insert the data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;lab_results&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;result_id&lt;/span&gt; &lt;span class="nb"&gt;SERIAL&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;patient_name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;test_name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;result_value&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;result_status&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the structure exists, you can insert rows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;lab_results&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;patient_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result_status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Anna Keller'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Blood Glucose'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'92 mg/dL'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'normal'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Matei Ionescu'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'White Blood Cells'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'12.1 x10^9/L'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'high'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the data appears in a table:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdtz0t9ifu4asud0gz22e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdtz0t9ifu4asud0gz22e.png" width="590" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a visual database GUI, this process becomes easier to follow: first, the table is created, then rows are inserted, and finally, the data appears in table view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2uplpesrgo7rcxq4as4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2uplpesrgo7rcxq4as4t.png" alt="PostgreSQL example showing CREATE TABLE, INSERT INTO, and inserted rows in a table" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PostgreSQL requires the table structure before inserting data.&lt;/p&gt;

&lt;p&gt;MongoDB works differently. You can insert the document directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;labResults&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insertOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;patientName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Anna Keller&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;testName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Blood Glucose&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;resultValue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;92 mg/dL&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;resultStatus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;normal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the structure comes from the document you insert.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkxe0zb6w5el0w9chipa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkxe0zb6w5el0w9chipa.png" alt="MongoDB insertMany example showing lab results documents created after inserting data" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MongoDB creates the collection and document structure when data is inserted.&lt;/p&gt;

&lt;p&gt;In MongoDB, we do not need to create the collection structure first. When we insert the document, MongoDB creates the collection and stores the fields from the document.  &lt;/p&gt;

&lt;p&gt;So, in simple words:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;PostgreSQL&lt;/em&gt;&lt;/strong&gt;: create the structure first, then insert data.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;MongoDB&lt;/em&gt;&lt;/strong&gt;: insert the document first, and the structure appears from the data.&lt;/p&gt;

&lt;p&gt;If you want more control, MongoDB also lets you add &lt;em&gt;*&lt;strong&gt;&lt;em&gt;validation rules&lt;/em&gt;&lt;/strong&gt;*&lt;/em&gt; later. We explain this step by step in our article about &lt;a href="https://visualeaf.com/blog/mongodb-json-schema-validation/" rel="noopener noreferrer"&gt;MongoDB JSON Schema Validation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data Querying: SQL JOINs vs Document-Based Querying
&lt;/h2&gt;

&lt;p&gt;The second difference after the storage is in querying.&lt;/p&gt;

&lt;p&gt;In PostgreSQL, data is stored in separate tables, which requires us to query using &lt;code&gt;JOIN&lt;/code&gt; to combine relevant data.&lt;/p&gt;

&lt;p&gt;For instance, if we would like to get clinic visits where both patients' and doctors' names are included, our query will be something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; 
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointment_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;patient_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;doctor_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;specialization&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointment_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;doctors&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fci75wi99l03j2w9jo43u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fci75wi99l03j2w9jo43u.png" alt="PostgreSQL query in VisuaLeaf joining appointments, patients, and doctors, with combined results displayed in a table." width="800" height="672"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PostgreSQL JOIN query combining appointments, patients, and doctors.&lt;/p&gt;

&lt;p&gt;When using MongoDB, the data is stored close together within the document. Therefore, you would not need to join multiple tables, as the following MongoDB command can be used to obtain the information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;visits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;doctor.specialization&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cardiology&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;completed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78cgrbwfz6pbq6c31pu2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78cgrbwfz6pbq6c31pu2.png" alt="MongoDB query in VisuaLeaf filtering clinic visits by doctor specialization and status, with results shown in Tree View." width="800" height="672"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MongoDB query result showing a nested clinic visit document.&lt;/p&gt;

&lt;p&gt;If you need the entire visit record containing all the required data, it would make sense to choose this approach.&lt;/p&gt;

&lt;p&gt;MongoDB can also join data when needed, using stages like &lt;code&gt;$lookup&lt;/code&gt; or &lt;code&gt;$graphLookup&lt;/code&gt; in the aggregation pipeline, but in many document models, the goal is to store related data together when it is usually read together.&lt;/p&gt;

&lt;p&gt;Here are the key differences to remember:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;PostgreSQL&lt;/em&gt;&lt;/strong&gt; relies on joins to obtain related data.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;MongoDB&lt;/em&gt;&lt;/strong&gt; queries documents containing all the related data.&lt;/p&gt;
&lt;h2&gt;
  
  
  Transactions and ACID: Saving Changes Safely
&lt;/h2&gt;

&lt;p&gt;A transaction means that several database changes are treated as one safe operation.&lt;/p&gt;

&lt;p&gt;Think about a clinic visit. When the visit is finished, the system may need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mark the visit as completed&lt;/li&gt;
&lt;li&gt;save the prescription&lt;/li&gt;
&lt;li&gt;create the invoice&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Such operations have something in common. If one operation fails to complete, the whole group of operations should be rolled back, not just a part of them.&lt;/p&gt;

&lt;p&gt;The logic of ACID transactions lies right there: *&lt;strong&gt;&lt;em&gt;Either all is saved, or nothing is changed at all&lt;/em&gt;&lt;/strong&gt;*.&lt;/p&gt;
&lt;h3&gt;
  
  
  Transaction in PostgreSQL
&lt;/h3&gt;

&lt;p&gt;As we know, PostgreSQL separates data into different tables. Therefore, a transaction is able to update multiple related tables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  

&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;appointments&lt;/span&gt;  
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'completed'&lt;/span&gt;  
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;appointment_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  

&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;prescriptions&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appointment_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;medication_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dosage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;duration_days&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Skin cream'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Apply twice daily'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  

&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;invoices&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appointment_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payment_status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'pending'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  

&lt;span class="k"&gt;COMMIT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, PostgreSQL updates the appointment, adds the prescription, and creates the invoice as one operation.&lt;/p&gt;

&lt;p&gt;You can check the result with a query like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flidejpl3wdcg9batg6q3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flidejpl3wdcg9batg6q3.png" alt="PostgreSQL transaction result showing appointment, prescription, and invoice" width="800" height="656"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PostgreSQL transaction result showing appointment, prescription, and invoice.&lt;/p&gt;

&lt;p&gt;After the transaction runs, the appointment is marked as completed, the prescription is added, and the invoice is created.&lt;/p&gt;

&lt;h3&gt;
  
  
  Transaction in MongoDB
&lt;/h3&gt;

&lt;p&gt;In this case, for the database MongoDB, the update is more straightforward since the data is within the same document.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;visits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;updateOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;visitId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;VIS-1003&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="na"&gt;$set&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;completed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
&lt;span class="na"&gt;prescriptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="na"&gt;medicationName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Skin cream&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
&lt;span class="na"&gt;dosage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Apply twice daily&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
&lt;span class="na"&gt;durationDays&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;],&lt;/span&gt;  
&lt;span class="na"&gt;invoice&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;95.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
&lt;span class="na"&gt;paymentStatus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pending&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
&lt;span class="na"&gt;issuedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This update is for a one-visit document. The status, prescriptions, and invoices are saved in the same document.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr0lfo7tmimuz450x4tft.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr0lfo7tmimuz450x4tft.png" alt="MongoDB update result showing completed visit with prescription and invoice" width="800" height="656"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MongoDB update result showing the visit document updated in one place.&lt;/p&gt;

&lt;p&gt;It is possible to have multi-document transactions in MongoDB. However, since the relevant visit information is kept in the same document, one document is enough.&lt;/p&gt;

&lt;p&gt;Hence, it is not because only PostgreSQL uses transaction management.&lt;/p&gt;

&lt;p&gt;Transaction management is available in both PostgreSQL and MongoDB.&lt;/p&gt;

&lt;p&gt;The critical point is that transaction management will be required for PostgreSQL because the data is stored in separate tables, whereas in MongoDB, all relevant data may be put in one document.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance: Which One Is Faster?
&lt;/h2&gt;

&lt;p&gt;Many people ask which solution will give them more speed. The answer is not straightforward.&lt;/p&gt;

&lt;p&gt;MongoDB is not faster in every case. PostgreSQL is not faster in every case either.&lt;/p&gt;

&lt;p&gt;Both solutions can work fast, and both can work slowly.&lt;/p&gt;

&lt;p&gt;It depends on the model design, the way you write the queries, and whether the right indexes are present.&lt;/p&gt;

&lt;p&gt;To make this more practical, I used the same question in both databases:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Show completed cardiology visits.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In &lt;strong&gt;&lt;em&gt;PostgreSQL&lt;/em&gt;&lt;/strong&gt;, the query joins the &lt;code&gt;appointments&lt;/code&gt;, &lt;code&gt;patients&lt;/code&gt;, and &lt;code&gt;doctors&lt;/code&gt; tables to build the result.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4btxwz4s8sec7u1znz3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4btxwz4s8sec7u1znz3.png" alt="PostgreSQL EXPLAIN ANALYZE plan in VisuaLeaf for a clinic query joining appointments, patients, and doctors." width="800" height="597"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PostgreSQL query plan for finding completed cardiology visits through related tables.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In &lt;strong&gt;&lt;em&gt;MongoDB&lt;/em&gt;&lt;/strong&gt;, the result can be read from the &lt;code&gt;visits&lt;/code&gt; collection, because the visit details are stored inside the document.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frpgikvbronlvcvae840j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frpgikvbronlvcvae840j.png" alt="MongoDB query analysis in VisuaLeaf showing index usage for completed cardiology visits." width="800" height="611"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MongoDB query analysis for finding completed cardiology visits in one collection.&lt;/p&gt;

&lt;p&gt;This is not meant to prove that one database is always faster. The example is small, and real performance depends on the amount of data, indexes, schema design, and query patterns.&lt;/p&gt;

&lt;p&gt;But it shows the idea clearly: PostgreSQL often builds the answer by connecting tables, while MongoDB can read related data from one document when the model is designed that way.&lt;/p&gt;

&lt;p&gt;Instead of asking:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which solution is faster?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You should ask:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which database suits the way my app reads and writes data?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That question is more useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scaling: Expanding from 2 TB to 4 TB
&lt;/h2&gt;

&lt;p&gt;When talking about scaling, we discuss how we should help our database support larger volumes, more users, or an increasing number of requests.&lt;/p&gt;

&lt;p&gt;One possible analogy may look like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;What will happen when our database grows from 2 TB to 4 TB?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When it comes to expanding PostgreSQL, most often we start with &lt;strong&gt;&lt;em&gt;scaling up&lt;/em&gt;&lt;/strong&gt;. We mean that we make our primary server even stronger by adding more computing power, additional memory, etc. Also, read replicas may be used, but our core database is still built around the single main server.&lt;/p&gt;

&lt;p&gt;As far as scaling MongoDB, it is done with &lt;strong&gt;&lt;em&gt;scaling out&lt;/em&gt;&lt;/strong&gt;, using the technique called sharding. Here, the data is distributed between different servers.&lt;/p&gt;

&lt;p&gt;Let us take, for instance, our &lt;code&gt;visits&lt;/code&gt; collection. It may stay the same collection; however, its documents will be spread between several shards. Which shard will store which documents depends on the chosen shard key, e.g., &lt;code&gt;clinicId&lt;/code&gt;, &lt;code&gt;region&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbe4i5fn76s96w63q5a16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbe4i5fn76s96w63q5a16.png" alt="PostgreSQL vs MongoDB scaling" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PostgreSQL usually scales by making one main server stronger, while MongoDB can scale by spreading one collection across multiple shards.&lt;/p&gt;

&lt;p&gt;As you see, the difference lies in:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;PostgreSQL grows through expanding the primary database.&lt;/em&gt;&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;MongoDB can scale by distributing its documents across multiple servers.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But it does not mean we should use MongoDB solely because of its scalability.&lt;/p&gt;

&lt;p&gt;Some projects will never require any form of sharding. But PostgreSQL is also capable of handling extremely large datasets with proper indexing, partitioning, replicas, and other techniques.&lt;/p&gt;

&lt;p&gt;However, the more pertinent question is whether or not:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Do I need one strong relational system, or do I expect my data to be distributed across multiple servers?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For this comparison, I used &lt;strong&gt;&lt;em&gt;VisuaLeaf&lt;/em&gt;&lt;/strong&gt;, a GUI tool that works with both NoSQL and SQL databases. It helped me view MongoDB documents and PostgreSQL tables in the same workspace. You can download it here: &lt;a href="https://visualeaf.com/" rel="noopener noreferrer"&gt;VisuaLeaf&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://visualeaf.com/download" rel="noopener noreferrer"&gt;Download for Free&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Which One Should You Choose?
&lt;/h2&gt;

&lt;p&gt;Go with &lt;a href="https://www.postgresql.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;PostgreSQL&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; if you have structured and relational data, and it relies heavily on rules.&lt;/p&gt;

&lt;p&gt;When PostgreSQL is the best choice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use tables with foreign keys&lt;/li&gt;
&lt;li&gt;apply joins&lt;/li&gt;
&lt;li&gt;make transactions&lt;/li&gt;
&lt;li&gt;generate reports&lt;/li&gt;
&lt;li&gt;have consistency of the data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use &lt;a href="https://www.mongodb.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;MongoDB&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; if you have flexible and nested data and it is more convenient to work with documents.&lt;/p&gt;

&lt;p&gt;When MongoDB is better:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use JSON documents&lt;/li&gt;
&lt;li&gt;have flexible fields&lt;/li&gt;
&lt;li&gt;have nested structure&lt;/li&gt;
&lt;li&gt;change the structure fast&lt;/li&gt;
&lt;li&gt;have data that is used together&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Therefore, there is no question about which database management system is better.&lt;/p&gt;

&lt;p&gt;You should choose the one that corresponds to how your application works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;MongoDB and PostgreSQL both provide solutions for similar issues but through entirely separate paths.&lt;/p&gt;

&lt;p&gt;After building the same clinic example in both databases, the difference becomes pretty obvious: PostgreSQL makes the relationships visible, while MongoDB makes the full visit easier to read in one place.&lt;/p&gt;

&lt;p&gt;If you want to read more practical MongoDB guides, you can find them here: &lt;a href="https://visualeaf.com/blog/" rel="noopener noreferrer"&gt;MongoDB Articles&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>postgres</category>
      <category>nosql</category>
      <category>sql</category>
    </item>
    <item>
      <title>Free MongoDB GUI Tool for Developers, Students, and Teams</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Mon, 25 May 2026 07:35:36 +0000</pubDate>
      <link>https://forem.com/visualeaf/free-mongodb-gui-tool-for-developers-students-and-teams-44la</link>
      <guid>https://forem.com/visualeaf/free-mongodb-gui-tool-for-developers-students-and-teams-44la</guid>
      <description>&lt;p&gt;MongoDB is much easier to understand when you can actually see your data, not just read it on a screen.&lt;/p&gt;

&lt;p&gt;The whole point of &lt;a href="https://visualeaf.com" rel="noopener noreferrer"&gt;VisuaLeaf&lt;/a&gt; is to make this happen.&lt;/p&gt;

&lt;p&gt;VisuaLeaf gives you a way to work with MongoDB that's easy to look at, and it still uses the real MongoDB syntax. You can look at your databases, open up collections, check out the documents, run queries, change values, and use the MongoDB shell when you need to be in control.&lt;/p&gt;

&lt;p&gt;This is really helpful for students who are learning MongoDB, for developers who are testing data on their computers, or for anyone who wants a better way to look at their MongoDB collections.&lt;/p&gt;

&lt;p&gt;The VisuaLeaf Community Edition has all the tools you need to get your work done every day: it lets you connect to databases, browse collections, run queries, edit things, access the shell, and do basic database management.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fchu2389qed1rz1zr7dlu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fchu2389qed1rz1zr7dlu.png" alt="VisuaLeaf showing a MongoDB students collection in Tree View with nested fields and indexes." width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Connect to MongoDB
&lt;/h2&gt;

&lt;p&gt;The first step is to &lt;a href="https://visualeaf.com/features/connection-manager/" rel="noopener noreferrer"&gt;connect to your MongoDB instance.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can paste your MongoDB connection string. It will fill in the form for you. Then you can test if the connection works and save it for use. This method works for both MongoDB instances and remote clusters.&lt;/p&gt;

&lt;p&gt;Once you save the connection, your databases and collections will show up in the panel. You can then explore them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3x1srd3r3ojmabko50qj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3x1srd3r3ojmabko50qj.png" alt="VisuaLeaf new MongoDB connection window with connection string and authentication settings." width="800" height="729"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Browse collections visually
&lt;/h2&gt;

&lt;p&gt;After you connect, you can &lt;a href="https://visualeaf.com/docs/collection-view" rel="noopener noreferrer"&gt;open a collection&lt;/a&gt;, right from the sidebar.&lt;/p&gt;

&lt;p&gt;For example, if you open the &lt;code&gt;students&lt;/code&gt; collection, you will see all the documents in the workspace. You can expand each document. See the fields, values, and data types.&lt;/p&gt;

&lt;p&gt;This is really helpful because MongoDB documents can be complex. A document can have things like nested objects, lists, dates, and different types of values.&lt;/p&gt;

&lt;p&gt;When you expand everything step by step, the structure of the collection becomes much clearer with the &lt;code&gt;students&lt;/code&gt; collection and its documents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foqavj65zlgnakresgd7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foqavj65zlgnakresgd7g.png" alt="VisuaLeaf showing a MongoDB students collection in Tree View with nested fields and indexes." width="800" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Viewing in Tree, Table, JSON, and BSON modes
&lt;/h2&gt;

&lt;p&gt;Various operations require different views.&lt;/p&gt;

&lt;p&gt;When you need to analyze nested documents, Tree View will do the job. For comparing multiple documents, use Table View. JSON mode gives you an understanding of the document format, while MongoDB-specific datatypes are more easily analyzed using BSON.&lt;/p&gt;

&lt;p&gt;Therefore, instead of analyzing the same data set in one view only, you have access to all the available views depending on the operation performed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhv6ho24s773auzsx1iia.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhv6ho24s773auzsx1iia.png" alt="VisuaLeaf showing a MongoDB collection in Table View with options to switch to Tree, JSON, and BSON." width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Run MongoDB queries
&lt;/h2&gt;

&lt;p&gt;When you have a collection open, you can look at the data you want by writing a MongoDB query in JSON format.&lt;/p&gt;

&lt;p&gt;For example, in a &lt;code&gt;students&lt;/code&gt; collection, you may want to find students from the Web Development program who are in year 1 or above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"program"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Web Development"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"year"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"$gte"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, you are using MongoDB syntax, which is helpful if you are learning MongoDB queries.&lt;/p&gt;

&lt;p&gt;You are not just clicking buttons without knowing what is happening. You write the MongoDB query, run the MongoDB query, and then look at the results to see what the MongoDB query did.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finnvpj6w33crph5sba60.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finnvpj6w33crph5sba60.png" alt="VisuaLeaf showing a MongoDB JSON query and the matching results in Table View." width="799" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Run aggregation pipelines
&lt;/h2&gt;

&lt;p&gt;Sometimes a simple query is not enough. I need to do more with my data.&lt;/p&gt;

&lt;p&gt;Maybe I want to group documents count how many there are, sort them in a way or figure out some numbers like averages. That's where MongoDB aggregation pipelines come in handy.&lt;/p&gt;

&lt;p&gt;In VisuaLeaf I can build an aggregation pipeline visually. I add stages like &lt;code&gt;Match&lt;/code&gt; &lt;code&gt;Group&lt;/code&gt; and &lt;code&gt;Sort&lt;/code&gt;. Then I configure each one. I can see the results as I go which is really helpful.&lt;/p&gt;

&lt;p&gt;For example lets say I have a &lt;code&gt;students&lt;/code&gt; collection. I can group students, by program, and calculate their average score.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"$match"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"active"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"$group"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$program"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"students"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"$sum"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"averageScore"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"$avg"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$progress.averageScore"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"$sort"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"students"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-1&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is useful because you do not read documents one by one. You start to understand patterns inside the data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faqjc7772gsvg7w7dijph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faqjc7772gsvg7w7dijph.png" alt="VisuaLeaf visual aggregation builder showing Match, Group, and Sort stages with live preview results." width="800" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The results are shown to you in a way that makes it easier to follow what each stage of the data is doing.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Use the MongoDB shell when you want to write commands
&lt;/h2&gt;

&lt;p&gt;Use the MongoDB shell when you want to type commands.&lt;/p&gt;

&lt;p&gt;Some tasks still feel better when done from the shell.&lt;/p&gt;

&lt;p&gt;That is why VisuaLeaf lets you write MongoDB commands directly without leaving your workspace.&lt;/p&gt;

&lt;p&gt;For example you can type a command, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;students&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;program&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Web Development&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;active&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps if you want to learn MongoDB syntax not just click through a visual interface.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2ivaecx7w8dbeg03qdf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2ivaecx7w8dbeg03qdf.png" alt="Mongodb Shell in VisuaLeaf " width="800" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The difference is that you are not limited to the terminal. You can write a command, run it, and still look at your database visually in the tool.&lt;/p&gt;

&lt;p&gt;For beginners, this is a balance: you learn MongoDB commands and see your data at the same time.&lt;/p&gt;

&lt;p&gt;This way, you learn MongoDB.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Insert and edit documents
&lt;/h2&gt;

&lt;p&gt;A student document in MongoDB is usually stored in JSON format, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"fullName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Grace Bennett"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"grace.bennett@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"program"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Web Development"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"year"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"skills"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"HTML"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"CSS"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"JavaScript"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Bristol"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"United Kingdom"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The thing about JSON is that it is flexible. It can be really easy to make mistakes when you are editing it by hand. You have to be careful.&lt;/p&gt;

&lt;p&gt;In VisuaLeaf, you can open the student document in Tree View or Table View. Update the values directly. For example, if a student decides to change their specialization, you can change the &lt;code&gt;program&lt;/code&gt; field from &lt;code&gt;Web Development&lt;/code&gt; to &lt;code&gt;MongoDB Development&lt;/code&gt; without having to write an &lt;code&gt;updateOne()&lt;/code&gt; command in the shell.&lt;/p&gt;

&lt;p&gt;You can make changes by editing the value directly and then applying the update.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fxih61xlwueomria4za.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fxih61xlwueomria4za.png" alt="VisuaLeaf showing a MongoDB student document edited directly in Tree View." width="800" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Create Databases and Collections Visually
&lt;/h2&gt;

&lt;p&gt;When you start a project, you usually need a database first, then a collection.&lt;/p&gt;

&lt;p&gt;You can make a database and a collection from the shell. It is easier to do it visually sometimes.&lt;/p&gt;

&lt;p&gt;In VisuaLeaf, you can make a database from the sidebar. Then you can make a collection using a form where you add the collection name, and that is it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xertvfh9d78ln7ny5he.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xertvfh9d78ln7ny5he.png" alt="VisuaLeaf dialog for creating a new MongoDB database" width="607" height="262"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For collections, you may only need a name for the collection, and you can also add a comment if you want to.&lt;/p&gt;

&lt;p&gt;This is especially helpful for people who are new to MongoDB because it shows the MongoDB structure more clearly:&lt;/p&gt;

&lt;p&gt;Database → Collection → Document&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fscop20pc3pzurrwwm7jz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fscop20pc3pzurrwwm7jz.png" alt="VisuaLeaf Create Collection screen with basic setup, validation rules, advanced options, and time series settings." width="800" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your project needs more control, you can also set up advanced options for the collection, such as capped collections, storage engine options, validation rules, index defaults, collation, views, or time series settings for the collection.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Create and view indexes
&lt;/h2&gt;

&lt;p&gt;Indexes are super important when your MongoDB queries start to slow down.&lt;/p&gt;

&lt;p&gt;When you do not have an index, MongoDB has to look through a lot of documents to find what you need. With the right index, MongoDB can find the data way faster.&lt;/p&gt;

&lt;p&gt;You can make an index in the MongoDB shell using &lt;code&gt;createIndex()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example, if you often sort students by when they &lt;em&gt;*&lt;strong&gt;&lt;em&gt;joined&lt;/em&gt;&lt;/strong&gt;*&lt;/em&gt; and filter them by &lt;em&gt;*&lt;strong&gt;&lt;em&gt;program&lt;/em&gt;&lt;/strong&gt;*&lt;/em&gt; and &lt;em&gt;*&lt;strong&gt;&lt;em&gt;status&lt;/em&gt;&lt;/strong&gt;*&lt;/em&gt;, you can make an index like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;students&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;program&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;joinedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fad58eva7m11hewgmtlld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fad58eva7m11hewgmtlld.png" alt="VisuaLeaf showing a MongoDB createIndex command and the new index under the students collection." width="800" height="535"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you make the index you can see it in the panel under the students collection.&lt;/p&gt;

&lt;p&gt;This is really helpful because you learn the MongoDB command and you also get to see which indexes are on the collection, in a visual way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who is this free MongoDB GUI tool for?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://visualeaf.com" rel="noopener noreferrer"&gt;The VisuaLeaf Community Edition&lt;/a&gt;, is a great tool if you want a free and easy way to work with MongoDB.&lt;/p&gt;

&lt;p&gt;It is useful for people who want to make working with MongoDB simpler.&lt;/p&gt;

&lt;p&gt;It can help people like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a student who is learning MongoDB&lt;/li&gt;
&lt;li&gt;a developer who is testing data on their computer&lt;/li&gt;
&lt;li&gt;a backend developer who works with MongoDB collections every day&lt;/li&gt;
&lt;li&gt;someone who wants to look at documents without only using the command line&lt;/li&gt;
&lt;li&gt;someone who wants to look at, change, search, and make groups of data visually, and also make indexes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea of the VisuaLeaf Community Edition is simple: you still get to learn real MongoDB, but you get a visual workspace to work with MongoDB.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It becomes easier to get clarity about the structure of data in MongoDB if it can be visually represented.&lt;/p&gt;

&lt;p&gt;Using VisuaLeaf Community Edition, you can connect to MongoDB and perform various operations like querying databases, building aggregations, executing shell commands, editing documents, creating collections, and viewing indexes on one screen.&lt;/p&gt;

&lt;p&gt;This makes it an effective free GUI for MongoDB that can be used by students and professionals for various purposes.&lt;/p&gt;

&lt;p&gt;In addition to this, VisuaLeaf offers you the facility to experience advanced functionality like its query builder and analytics dashboard free for 14 days.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>nosql</category>
      <category>database</category>
      <category>data</category>
    </item>
    <item>
      <title>VisuaLeaf is mentioned in this article as one of the 7 best MongoDB tools tested.

Thank you!</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Fri, 08 May 2026 10:27:29 +0000</pubDate>
      <link>https://forem.com/visualeaf/visualeaf-is-mentioned-in-this-article-as-one-of-the-7-best-mongodb-tools-testedthank-you-20i5</link>
      <guid>https://forem.com/visualeaf/visualeaf-is-mentioned-in-this-article-as-one-of-the-7-best-mongodb-tools-testedthank-you-20i5</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/roxana_haidiner/best-mongodb-database-tools-in-2026-2i30" class="crayons-story__hidden-navigation-link"&gt;What is the Best MongoDB Database Tool in 2026?&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/roxana_haidiner" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2224346%2Ff71cca7a-b282-4793-a3ae-b04d89957d47.png" alt="roxana_haidiner profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/roxana_haidiner" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Roxana-Maria Haidiner
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Roxana-Maria Haidiner
                
              
              &lt;div id="story-author-preview-content-3625610" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/roxana_haidiner" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2224346%2Ff71cca7a-b282-4793-a3ae-b04d89957d47.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Roxana-Maria Haidiner&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/roxana_haidiner/best-mongodb-database-tools-in-2026-2i30" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;May 7&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/roxana_haidiner/best-mongodb-database-tools-in-2026-2i30" id="article-link-3625610"&gt;
          What is the Best MongoDB Database Tool in 2026?
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/mongodb"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;mongodb&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/database"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;database&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/nosql"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;nosql&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/roxana_haidiner/best-mongodb-database-tools-in-2026-2i30" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;5&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/roxana_haidiner/best-mongodb-database-tools-in-2026-2i30#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              1&lt;span class="hidden s:inline"&gt; comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            12 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Automate MongoDB Exports, Imports, and Sync Jobs with VisuaLeaf</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Thu, 07 May 2026 21:00:00 +0000</pubDate>
      <link>https://forem.com/visualeaf/automate-mongodb-exports-imports-and-sync-jobs-with-visualeaf-476c</link>
      <guid>https://forem.com/visualeaf/automate-mongodb-exports-imports-and-sync-jobs-with-visualeaf-476c</guid>
      <description>&lt;p&gt;Not all MongoDB jobs are hard to perform since their implementation is usually not that complicated. But their frustration arises from having to do them time after time.&lt;/p&gt;

&lt;p&gt;Export the same collection.&lt;br&gt;
Import the other document into the database.&lt;br&gt;
Transfer the same set of data between environments.&lt;br&gt;
Do the job again the following week and then the next month.&lt;/p&gt;

&lt;p&gt;Now, the actual problem that you need to solve is not about figuring out how to execute the operation just once. It is about executing it in a &lt;strong&gt;reliable&lt;/strong&gt;, &lt;strong&gt;consistent&lt;/strong&gt; way, without having to rebuild the process over and over.&lt;/p&gt;

&lt;p&gt;This is exactly what &lt;a href="https://visualeaf.com/features/task-manager/" rel="noopener noreferrer"&gt;&lt;strong&gt;Task Manager&lt;/strong&gt;&lt;/a&gt; in VisuaLeaf allows for. Specifically, it is created to schedule and manage background jobs for &lt;strong&gt;exports, imports, sync jobs&lt;/strong&gt;, and any other recurring database operations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fboext9ha45aqqo48uqck.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fboext9ha45aqqo48uqck.png" alt="Task Manager gives you a central place to create, organize, and run recurring MongoDB jobs." width="800" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  When manual MongoDB work starts becoming a problem
&lt;/h2&gt;

&lt;p&gt;At first, performing operations manually doesn’t seem like such a big problem.&lt;/p&gt;

&lt;p&gt;You open the collection, perform the export/import/synchronization of your file, and continue working.&lt;/p&gt;

&lt;p&gt;However, after some time, the very process of doing this starts to create difficulties for you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;wasting time reinitializing your settings&lt;/li&gt;
&lt;li&gt;making it easy to miss a step&lt;/li&gt;
&lt;li&gt;relying too heavily on your own memory&lt;/li&gt;
&lt;li&gt;inability to track what happened once the operation was performed&lt;/li&gt;
&lt;li&gt;complications with performing the same operations in multiple environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is situations such as these that demonstrate the need for automation – not necessarily for the complexity that the latter implies, but simply because any repetitive task should eventually turn into a reusable process.&lt;/p&gt;

&lt;h3&gt;
  
  
  The way the VisuaLeaf Task Manager works
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://visualeaf.com/" rel="noopener noreferrer"&gt;VisuaLeaf&lt;/a&gt; Task Manager is not limited to scheduling a process at a specified time. This functionality is focused on performing repeatable actions with data, which makes it highly relevant to database operations.&lt;/p&gt;

&lt;p&gt;Export, import, and sync operations can be performed with the help of Task Manager; they are executed either once or regularly within certain time intervals ranging from hourly to monthly or even defined by cron expressions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqszwbv3u5jbuuplqhxgi.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqszwbv3u5jbuuplqhxgi.webp" alt="Task Manager showing recurring schedules: hourly, daily, weekly, monthly, and custom." width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, the user will know more about the process itself through access to information about the execution results, such as status, history, execution errors, number of processed and failing records, run time, and execution control tools such as starting, stopping, resuming, editing, duplicating, and deleting.&lt;/p&gt;

&lt;p&gt;Why do we need this feature? It makes the scheduler tool a part of the workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  An interesting real-world scenario: transferring a collection from one database to another.
&lt;/h2&gt;

&lt;p&gt;Another good example illustrating the value of Task Manager would be the process of transferring a collection from one database to another.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjid4t20scupv2nadukco.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjid4t20scupv2nadukco.webp" alt="Setting up a collection sync job between MongoDB environments." width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This may be necessary to maintain synchronization between different environments, prepare a new test environment with a replica of production data, and other similar cases. Although the task itself is usually simple, performing such operations manually becomes tedious very quickly.&lt;/p&gt;

&lt;p&gt;Task Manager can be applied to address this issue since it allows treating data transfer operations as reusable processes rather than one-time tasks. You will be able to specify the source, target databases, and schedules only once, storing the configuration for further use. Then, you can perform the process repeatedly, make changes, create copies, and analyze results without having to start everything from scratch every single time.&lt;/p&gt;

&lt;h2&gt;
  
  
  However, Task Manager is useful not only for the migration of collections
&lt;/h2&gt;

&lt;p&gt;Besides the ability to migrate a collection between databases, there are other operational tasks that can be performed on the fly by Task Manager. These are:&lt;/p&gt;

&lt;h3&gt;
  
  
  Periodic exports
&lt;/h3&gt;

&lt;p&gt;Task Manager offers the possibility of exporting data in formats such as &lt;strong&gt;JSON&lt;/strong&gt;, &lt;strong&gt;CSV&lt;/strong&gt;, &lt;strong&gt;BSON&lt;/strong&gt;, and &lt;strong&gt;SQL INSERT commands&lt;/strong&gt;. That way, it may prove helpful during backups and reporting, during data handoffs or even migrations, if an external application relies either on receiving a file or SQL-like queries as input.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx9d0wzk0180fhv18a30.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx9d0wzk0180fhv18a30.webp" alt="Creating a CSV export job in VisuaLeaf Task Manager." width="800" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Periodic imports
&lt;/h3&gt;

&lt;p&gt;It also allows importing data in formats such as &lt;strong&gt;JSON&lt;/strong&gt;, &lt;strong&gt;CSV&lt;/strong&gt;, and &lt;strong&gt;BSON&lt;/strong&gt;, including the ability of performing transformations or mappings, and even using the upsert mode, which means updating the document if it already exists, rather than inserting it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyub74cjs5y3r651ewfca.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyub74cjs5y3r651ewfca.webp" alt="Setting up an import job in VisuaLeaf Task Manager." width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Synchronization workflows
&lt;/h3&gt;

&lt;p&gt;Task Manager may prove extremely useful for periodic synchronization scenarios, too, particularly for organizations relying on different environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  The importance of monitoring on par with scheduling
&lt;/h2&gt;

&lt;p&gt;There is a variety of tools that help you schedule a particular job.&lt;/p&gt;

&lt;p&gt;That is not the important thing here.&lt;/p&gt;

&lt;p&gt;The real deal is what goes on once the job is started:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is it completed?&lt;/li&gt;
&lt;li&gt;Have there been any errors?&lt;/li&gt;
&lt;li&gt;How many documents have been processed?&lt;/li&gt;
&lt;li&gt;Have there been any misses?&lt;/li&gt;
&lt;li&gt;What is the duration of it?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the most valuable functions of the feature. Task Manager allows you to track progress, view the execution history, monitor errors, status of tasks, and their stats, thus eliminating the guesswork about what has happened after each run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flulx3z7kd4cbeepm1pn0.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flulx3z7kd4cbeepm1pn0.webp" alt="Tracking task history and success rates in VisuaLeaf Task Manager." width="800" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Monitoring becomes an essential part of value here as jobs are being run weekly or even daily.&lt;/p&gt;

&lt;h2&gt;
  
  
  Another reason this feature is practical: transformations
&lt;/h2&gt;

&lt;p&gt;Simple data scheduling can transfer data.&lt;/p&gt;

&lt;p&gt;A more advanced workflow tool will make it possible for you to work with your data while moving it.&lt;/p&gt;

&lt;p&gt;As we can see from the documentation, Task Manager allows for field mapping, type conversion, filtering, custom JavaScript transformations, and even aggregation pipeline processing before export.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsric84qk7aseoqyrkee.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsric84qk7aseoqyrkee.webp" alt="Creating a fullName field and previewing the result in the target collection." width="800" height="661"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is important because actual workflows are not about simply copying a collection. Instead, you often need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rename fields&lt;/li&gt;
&lt;li&gt;change types&lt;/li&gt;
&lt;li&gt;filter out unused records&lt;/li&gt;
&lt;li&gt;do partial exports&lt;/li&gt;
&lt;li&gt;clean data before migration rather than after&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that will save you much trouble later on.&lt;/p&gt;

&lt;h2&gt;
  
  
  How this particular feature grows in value with time
&lt;/h2&gt;

&lt;p&gt;Some features seem useful from the very first moment that you use them.&lt;/p&gt;

&lt;p&gt;Task Manager is unique in its nature because it becomes even more useful the more frequently you repeat similar work of similar kind.&lt;/p&gt;

&lt;p&gt;First-time collection move does not mean that you need Task Manager.&lt;/p&gt;

&lt;p&gt;But the fifth one makes you think about its benefits.&lt;/p&gt;

&lt;p&gt;By the tenth move, you realize why it is the right thing for managing your MongoDB tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best practices for setting up recurring tasks
&lt;/h2&gt;

&lt;p&gt;Before turning a job into a recurring task, it is worth testing it manually first. It also makes sense to schedule heavier operations during off-peak hours, monitor the first runs carefully, and use incremental approaches when large datasets are involved.&lt;/p&gt;

&lt;p&gt;It makes sense because this demonstrates the actual purpose of Task Manager rather than simply showcasing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who does Task Manager benefit the most?
&lt;/h2&gt;

&lt;p&gt;While the obvious audience for this functionality is the developer community, this is not exclusively so.&lt;/p&gt;

&lt;p&gt;Task Manager can be particularly helpful for the following groups:&lt;/p&gt;

&lt;h3&gt;
  
  
  Teams who collaborate around MongoDB data
&lt;/h3&gt;

&lt;p&gt;For those on the team who find themselves exporting the database as a CSV or JSON file more than once, Task Manager provides an elegant way to eliminate redundancy.&lt;/p&gt;

&lt;h3&gt;
  
  
  People managing incoming files
&lt;/h3&gt;

&lt;p&gt;If you are working on the import of any files, the process of mapping and transforming the data takes on new importance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Users who prefer streamlined workflows
&lt;/h3&gt;

&lt;p&gt;Some people can work well within a purely manual framework. Some people would rather automate certain processes, minimize errors, and gain better insight into their operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://visualeaf.com/docs/task-manager" rel="noopener noreferrer"&gt;Task Manager&lt;/a&gt; is designed to help solve one of the most common challenges encountered when working with MongoDB: performing operations in an automated manner without relying on memory, repetitive actions, or having to reconstruct everything from scratch.&lt;/p&gt;

&lt;p&gt;When using VisuaLeaf, the feature enables automation for export, import, synchronization, and migration tasks, yet allows maintaining control over their execution.&lt;/p&gt;

&lt;p&gt;That is why it proves useful. Task Manager saves time and effort, yet also makes repeating your MongoDB work easy and controllable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try VisuaLeaf
&lt;/h2&gt;

&lt;p&gt;If you would like to try these scenarios for yourself, feel free to download VisuaLeaf at the link below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://visualeaf.com/download" rel="noopener noreferrer"&gt;Download VisuaLeaf&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  External resources
&lt;/h2&gt;

&lt;p&gt;To learn more about the mentioned MongoDB tools and concepts, you might consider these resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/docs/database-tools/mongoimport/" rel="noopener noreferrer"&gt;MongoDB &lt;code&gt;mongoimport&lt;/code&gt; documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/docs/database-tools/mongoexport/" rel="noopener noreferrer"&gt;MongoDB &lt;code&gt;mongoexport&lt;/code&gt; documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/docs/manual/core/aggregation-pipeline/" rel="noopener noreferrer"&gt;MongoDB Aggregation Pipeline documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://crontab.guru/" rel="noopener noreferrer"&gt;Crontab Guru - cron expression reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>mongodb</category>
      <category>nosql</category>
      <category>automation</category>
      <category>database</category>
    </item>
    <item>
      <title>How to Optimize MongoDB Query Performance with Indexes</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Thu, 07 May 2026 15:30:00 +0000</pubDate>
      <link>https://forem.com/visualeaf/how-to-optimize-mongodb-query-performance-with-indexes-289m</link>
      <guid>https://forem.com/visualeaf/how-to-optimize-mongodb-query-performance-with-indexes-289m</guid>
      <description>&lt;p&gt;Not all slow MongoDB queries are bad queries.&lt;/p&gt;

&lt;p&gt;Sometimes the query is fine, but MongoDB does not have a good index to help with your filtering, sorting, and retrieving of the data&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll use &lt;strong&gt;payments&lt;/strong&gt; as an example of our database. The collection starts without a useful index for our query. We'll identify the slow operation, learn about the recommended index, explain why the compound index works, and manage it visually in &lt;a href="https://visualeaf.com" rel="noopener noreferrer"&gt;VisuaLeaf&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegmux3qtvq7mtz4dk56e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegmux3qtvq7mtz4dk56e.png" alt="Payments collection in VisuaLeaf showing currency status amount and paidAt fields" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The workflow is simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;slow query -&amp;gt; query profiler -&amp;gt; index recommendation -&amp;gt; compound index -&amp;gt; index manager&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can use the same workflow when your own MongoDB collections start to feel slow.&lt;/p&gt;

&lt;h2&gt;
  
  
  On this page
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The Slow Query Problem&lt;/li&gt;
&lt;li&gt;The Payments Query We Want to Optimize&lt;/li&gt;
&lt;li&gt;Find the Slow Query in VisuaLeaf&lt;/li&gt;
&lt;li&gt;Read the Index Recommendation&lt;/li&gt;
&lt;li&gt;Why This Compound Index Works&lt;/li&gt;
&lt;li&gt;Check and Manage Indexes&lt;/li&gt;
&lt;li&gt;Indexing Mistakes to Avoid&lt;/li&gt;
&lt;li&gt;FAQ&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Slow Query Problem
&lt;/h2&gt;

&lt;p&gt;MongoDB can return results quickly when a collection is small.&lt;/p&gt;

&lt;p&gt;But as the collection grows, the same query can become slower. MongoDB may need to scan many documents, sort a large result set, or check fields that are not indexed.&lt;/p&gt;

&lt;p&gt;That extra work is the real problem.&lt;/p&gt;

&lt;p&gt;For example, this query looks simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the &lt;code&gt;status&lt;/code&gt; field has no useful index; MongoDB may scan the collection to find matching documents.&lt;/p&gt;

&lt;p&gt;This is called a collection scan.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu97qjo3rcgik17kfb9bl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu97qjo3rcgik17kfb9bl.png" alt="MongoDB Explain Plan showing COLLSCAN for payments query filtered by status paid" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A collection scan is not always bad. On a tiny collection, it may not matter. On a large collection used by your app every day, it matters a lot.&lt;/p&gt;

&lt;p&gt;When you inspect a query plan, these stages are important:&lt;/p&gt;

&lt;p&gt;A common warning sign looks like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;COLLSCAN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;MongoDB scanned the collection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;IXSCAN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;MongoDB used an index&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;FETCH&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;MongoDB fetched documents after using an index&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SORT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;MongoDB performed a sort operation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;totalDocsExamined: 50000
nReturned: 25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That means MongoDB checked 50,000 documents to return only 25.&lt;/p&gt;

&lt;p&gt;The goal is not just to make the query look cleaner. The goal is to make MongoDB do less work.&lt;/p&gt;

&lt;p&gt;MongoDB explains the technical index behavior in the official &lt;a href="https://www.mongodb.com/docs/manual/indexes/" rel="noopener noreferrer"&gt;MongoDB Indexes documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Payments Query We Want to Optimize
&lt;/h2&gt;

&lt;p&gt;Now let’s use a more realistic query.&lt;/p&gt;

&lt;p&gt;Imagine you have a &lt;code&gt;payments&lt;/code&gt; collection, and you often need to find *&lt;strong&gt;&lt;em&gt;'paid'&lt;/em&gt;&lt;/strong&gt;* USD payments above a certain amount, sorted by the newest payment date.&lt;/p&gt;

&lt;p&gt;The query looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;USD&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;paidAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query does four things:&lt;/p&gt;

&lt;p&gt;If your &lt;code&gt;payments&lt;/code&gt; collection has no useful index for this pattern, MongoDB has to work harder than necessary.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;What the query does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;currency&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Keeps only payments in USD&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;status&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Keeps only paid payments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;amount&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Keeps payments greater than or equal to 100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;paidAt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sorts newest payments first&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A single-field index can help with simple filters, but this query uses multiple fields.&lt;/p&gt;

&lt;p&gt;That is why a compound index makes more sense here. It can support the filter, sort, and range condition together.&lt;/p&gt;

&lt;p&gt;We will let VisuaLeaf recommend the exact index after we inspect the slow query.&lt;/p&gt;

&lt;p&gt;MongoDB documents compound indexes in the official &lt;a href="https://www.mongodb.com/docs/manual/core/indexes/index-types/index-compound/" rel="noopener noreferrer"&gt;Compound Indexes documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Find the Slow Query in VisuaLeaf
&lt;/h2&gt;

&lt;p&gt;Do not create indexes because a field looks important.&lt;/p&gt;

&lt;p&gt;Find the slow query first. Then index the query pattern.&lt;/p&gt;

&lt;p&gt;Use the same payments query from the previous section in the Visual Query Builder. Add the filters for currency, status, and amount, then sort by paidAt descending.&lt;/p&gt;

&lt;p&gt;In VisuaLeaf, the Explain view shows the execution plan, scanned documents, returned documents, execution time, and index usage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9f8d9icplciqi8m8z8m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9f8d9icplciqi8m8z8m.png" alt="MongoDB Explain Plan in VisuaLeaf Query Builder showing collection scan and documents examined" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If MongoDB scans many documents and returns only a few, the query probably needs a better index.&lt;/p&gt;

&lt;p&gt;You can also run the same check manually with &lt;code&gt;explain()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;USD&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;paidAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;explain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;executionStats&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you read the result, check these values:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;What you check&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;totalDocsExamined&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How many documents MongoDB scanned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;nReturned&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How many documents MongoDB returned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;executionTimeMillis&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How long the query took&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;winningPlan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Which execution plan MongoDB selected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Look for IXSCAN when MongoDB uses an index, and COLLSCAN when MongoDB scans the collection. For one query, the Explain view is enough.&lt;/p&gt;

&lt;p&gt;For repeated slow operations across collections, use &lt;a href="https://visualeaf.com/features/query-profiler/" rel="noopener noreferrer"&gt;VisuaLeaf Query Profiling&lt;/a&gt;. The profiler helps you see slow operations over time, not just one query you are testing manually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywu7i3nutljt53y6dztg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywu7i3nutljt53y6dztg.png" alt="MongoDB Query Profiling Dashboard in VisuaLeaf showing slow operations" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MongoDB also provides database profiling features for slow operations. You can read more in the official &lt;a href="https://www.mongodb.com/docs/manual/tutorial/manage-the-database-profiler/" rel="noopener noreferrer"&gt;Database Profiler documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the Index Recommendation
&lt;/h2&gt;

&lt;p&gt;After you find the slow query, check which index would actually help.&lt;/p&gt;

&lt;p&gt;In this example, the &lt;code&gt;payments&lt;/code&gt; collection has no useful index for the query. VisuaLeaf detects repeated collection scans and recommends a &lt;strong&gt;&lt;em&gt;compound index&lt;/em&gt;&lt;/strong&gt; based on the fields used by the query.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftva42q5xsc0db2snnvzq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftva42q5xsc0db2snnvzq.png" alt="MongoDB index recommendations in VisuaLeaf showing the recommended compound index for the payments collection" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The recommendation for the &lt;strong&gt;&lt;em&gt;compound index&lt;/em&gt;&lt;/strong&gt; is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paidAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is useful because the recommendation does not only say “add an index.”&lt;/p&gt;

&lt;p&gt;It shows the exact fields and the order.&lt;/p&gt;

&lt;p&gt;That order is the important part.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Compound Index Works
&lt;/h2&gt;

&lt;p&gt;The recommended index matches the way the query filters and sorts the data.&lt;/p&gt;

&lt;p&gt;After creating the recommended index, run the same query again in the Explain view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F630gn3uwnaxf94iozl2x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F630gn3uwnaxf94iozl2x.png" alt="MongoDB Explain Plan in VisuaLeaf showing IXSCAN and compound index usage for payments query" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After creating the compound index, VisuaLeaf shows that MongoDB uses the index for the payments query.&lt;/p&gt;

&lt;p&gt;Now MongoDB uses the compound index instead of scanning the full collection.&lt;/p&gt;

&lt;p&gt;The query first filters by currency and status, then sorts by paidAt, and also applies a range condition on amount.&lt;/p&gt;

&lt;p&gt;In simple terms:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Why it is in the index&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;currency&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Exact filter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;status&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Exact filter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;paidAt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sort by newest payment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;amount&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Range condition&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Check and Manage Indexes
&lt;/h2&gt;

&lt;p&gt;After you create an index, check what exists in the collection.&lt;/p&gt;

&lt;p&gt;Indexes are easy to add and easy to forget.&lt;/p&gt;

&lt;p&gt;Over time, a collection can collect old indexes, duplicate indexes, or indexes created for queries that no longer exist.&lt;/p&gt;

&lt;p&gt;Use the &lt;a href="https://visualeaf.com/docs/index-management" rel="noopener noreferrer"&gt;Index Manager&lt;/a&gt; to review the indexes on your collection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqk029jce4f2tylh1ebz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqk029jce4f2tylh1ebz.png" alt="MongoDB Index Manager in VisuaLeaf showing indexes for a payments collection" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Index Manager helps you check the index name, fields, type, size, usage, properties, and status.&lt;/p&gt;

&lt;p&gt;This helps you avoid creating the same index twice.&lt;/p&gt;

&lt;p&gt;It also helps you review old indexes when your application queries change.&lt;/p&gt;

&lt;p&gt;You can combine this workflow with the &lt;a href="https://visualeaf.com/features/visual-query-builder/" rel="noopener noreferrer"&gt;Visual Query Builder&lt;/a&gt;, &lt;a href="https://visualeaf.com/features/mongo-shell/" rel="noopener noreferrer"&gt;MongoDB Shell&lt;/a&gt;, &lt;a href="https://visualeaf.com/features/aggregation-pipeline/" rel="noopener noreferrer"&gt;Aggregation Pipeline Builder&lt;/a&gt;, and &lt;a href="https://visualeaf.com/features/chart-builder/" rel="noopener noreferrer"&gt;Charts and Dashboards&lt;/a&gt; when you need to test, analyze, and present your MongoDB data.&lt;/p&gt;

&lt;p&gt;If you prefer, you can create the index visually from the Index Manager instead of writing the command manually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqxhffb0zne17a70ft0n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqxhffb0zne17a70ft0n.png" alt="Create MongoDB index visually in VisuaLeaf Index Manager with field direction and index options" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Indexing Mistakes to Avoid
&lt;/h2&gt;

&lt;p&gt;Indexes help when they match your workload.&lt;/p&gt;

&lt;p&gt;They create problems when you add them without a reason.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating indexes for every field
&lt;/h3&gt;

&lt;p&gt;Do not index every field in the collection.&lt;/p&gt;

&lt;p&gt;Each index needs storage. Each index also adds work when MongoDB inserts, updates, or deletes documents.&lt;/p&gt;

&lt;p&gt;Create indexes for queries your application actually runs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ignoring the sort
&lt;/h3&gt;

&lt;p&gt;A query may filter quickly but still sort slowly.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;paidAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A useful index is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paidAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This supports the filter and the sort.&lt;/p&gt;

&lt;h3&gt;
  
  
  Putting fields in the wrong order
&lt;/h3&gt;

&lt;p&gt;A compound index is not only about choosing the right fields. The order matters too.&lt;/p&gt;

&lt;p&gt;For the payments query, starting with the *&lt;strong&gt;&lt;em&gt;amount&lt;/em&gt;&lt;/strong&gt;* is not as useful as starting with the *&lt;strong&gt;&lt;em&gt;currency&lt;/em&gt;&lt;/strong&gt;* and *&lt;strong&gt;&lt;em&gt;status&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;, because the *&lt;/em&gt;&lt;strong&gt;amount&lt;/strong&gt;** is a range condition.&lt;/p&gt;

&lt;p&gt;Same fields. Different order. Different performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keeping indexes you no longer use
&lt;/h3&gt;

&lt;p&gt;Your application changes.&lt;/p&gt;

&lt;p&gt;Your queries change.&lt;/p&gt;

&lt;p&gt;Your indexes should change too.&lt;/p&gt;

&lt;p&gt;Review unused indexes from time to time and remove the ones that no longer support real queries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;MongoDB query optimization starts with the query pattern.&lt;/p&gt;

&lt;p&gt;Do not guess. Find the slow query first. Check whether MongoDB scans too many documents. Then create an index that matches how your query filters, sorts, and ranges over the data.&lt;/p&gt;

&lt;p&gt;For simple filters, a single field index may be enough.&lt;/p&gt;

&lt;p&gt;For queries like the &lt;code&gt;payments&lt;/code&gt; example, a compound index is usually better.&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://visualeaf.com/download" rel="noopener noreferrer"&gt;VisuaLeaf&lt;/a&gt;, you can detect slow queries, review index recommendations, and manage MongoDB indexes visually in one place.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>nosql</category>
      <category>database</category>
      <category>development</category>
    </item>
    <item>
      <title>How to Turn MongoDB Data into Charts and Dashboards</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Tue, 28 Apr 2026 12:31:51 +0000</pubDate>
      <link>https://forem.com/visualeaf/how-to-turn-mongodb-data-into-charts-and-dashboards-p43</link>
      <guid>https://forem.com/visualeaf/how-to-turn-mongodb-data-into-charts-and-dashboards-p43</guid>
      <description>&lt;p&gt;When you open a MongoDB collection, the data is all there, but that does not always mean it is easy to understand.&lt;/p&gt;

&lt;p&gt;You may have nested fields, many documents, different values, and too much information to scan manually. A raw collection can work as a storage view, but not always as a decision-making view.&lt;/p&gt;

&lt;p&gt;That is where a visual &lt;strong&gt;MongoDB&lt;/strong&gt; graphical user interface becomes useful.&lt;/p&gt;

&lt;p&gt;Instead of going through each document individually, you may transform your collection data into a chart, filter the information using a visual query builder, construct an aggregation, and combine everything on one dashboard. Here, the same data from MongoDB is more convenient to interpret, demonstrate, and even distribute as part of your &lt;a href="https://visualeaf.com/docs" rel="noopener noreferrer"&gt;&lt;strong&gt;MongoDB documentation&lt;/strong&gt;.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial, I will walk you through the process, from your collection data to your final dashboard, in just four steps.&lt;/p&gt;

&lt;p&gt;In this tutorial, I will walk you through the process, from your collection data to your final dashboard in just four steps.&lt;/p&gt;

&lt;p&gt;If you prefer a visual explanation, you can also watch the full video below.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/jkmyR7iYjIs"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Begin with a MongoDB Collection
&lt;/h2&gt;

&lt;p&gt;This is what your MongoDB data looks like.&lt;/p&gt;

&lt;p&gt;And here is what it looks like as a chart.&lt;/p&gt;

&lt;p&gt;The same data with an absolutely different level of transparency.&lt;/p&gt;

&lt;p&gt;You can directly start from a &lt;strong&gt;MongoDB collection&lt;/strong&gt; and make a chart based on it without doing any export to other tools.&lt;/p&gt;

&lt;p&gt;For instance, there could be a payments collection with plenty of documents with multiple fields, including dates. To understand the picture of what's happening in such a collection, one needs time, and even then, it is not easy to see the big picture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2w51hpur8hldi8rn00r.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2w51hpur8hldi8rn00r.webp" alt="Raw MongoDB payment data in a collection view." width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, you can open the collection in Charts, create a chart, and add a line chart.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32yn664skfv80e8m20g0.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32yn664skfv80e8m20g0.webp" alt="The same payment data shown as a line chart." width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, you need to pick out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the datetime of payment field&lt;/li&gt;
&lt;li&gt;the payment amount field&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In just a few seconds, the collection transforms into a chart reflecting the dynamics of payments.&lt;/p&gt;

&lt;p&gt;It is not always easy to understand what is going on in terms of JSON or table rows. A chart might be an option here. This is another reason why a &lt;strong&gt;MongoDB viewer&lt;/strong&gt; with &lt;a href="https://visualeaf.com/features/chart-builder/" rel="noopener noreferrer"&gt;charts support&lt;/a&gt; may be a more practical solution than regular document browsers.&lt;/p&gt;

&lt;p&gt;You may also rename the chart to something like &lt;strong&gt;Payments Over Time&lt;/strong&gt; and save it for future use.&lt;/p&gt;

&lt;p&gt;Now that the chart is ready, it can actually be used, as it provides you with an immediate idea of how the values change.&lt;/p&gt;

&lt;h2&gt;
  
  
  Raw Data Is Not Always the Data You Need
&lt;/h2&gt;

&lt;p&gt;The first chart has been built directly based on the raw collection.&lt;/p&gt;

&lt;p&gt;Of course, this helps get an immediate understanding, but in practice, it is very rare to need all the data at once. In most cases, what you need is exactly that part of the information that will help you to find the answers.&lt;/p&gt;

&lt;p&gt;It is when visual &lt;a href="https://visualeaf.com/blog/build-mongodb-queries-visually/" rel="noopener noreferrer"&gt;&lt;strong&gt;queries for MongoDB&lt;/strong&gt;&lt;/a&gt; come into play.&lt;/p&gt;

&lt;p&gt;Rather than typing the code yourself, you can transition to Query Builder and create your filter visually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fba9fr87d5f423t40vnrd.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fba9fr87d5f423t40vnrd.webp" alt="Visual filters applied in Query Builder to narrow the payment data." width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;select only transactions over 1000&lt;/li&gt;
&lt;li&gt;apply filters for currencies like USD and EUR&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now the result becomes more meaningful to analyze.&lt;/p&gt;

&lt;p&gt;You are not looking through the whole data anymore, but rather at a subset of the information you need.&lt;/p&gt;

&lt;p&gt;When you are done with filtering, you can proceed to the Chart view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkkdsslo2dw2wmaqbek0c.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkkdsslo2dw2wmaqbek0c.webp" alt="Bar chart created from the filtered payment results." width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this case, a bar chart would do perfectly well as you could easily:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;group data by countries&lt;/li&gt;
&lt;li&gt;set the amount as the value field&lt;/li&gt;
&lt;li&gt;set the status as the breakdown&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you see, there is already something to think about here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Go Beyond Visualization with Aggregation
&lt;/h2&gt;

&lt;p&gt;Data charts from filtered collections can be helpful, but there are times when filtering alone is not enough.&lt;/p&gt;

&lt;p&gt;There are cases where calculation is needed.&lt;/p&gt;

&lt;p&gt;That is why aggregation plays its role in transforming data from raw to insightful information.&lt;/p&gt;

&lt;p&gt;With a visual pipeline for building aggregations, you can simply drag and drop the needed stages, and you will immediately see how the output changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F748396zhwvsgauffmbwn.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F748396zhwvsgauffmbwn.webp" alt="Aggregation pipeline built visually with Match, Group, and Sort stages." width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For instance, you can use the following stages:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Match
&lt;/h3&gt;

&lt;p&gt;Select only those transactions that have a transaction value greater than 500.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Group
&lt;/h3&gt;

&lt;p&gt;Group all the documents according to their payment type and compute the total income by adding up the amounts.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Sort
&lt;/h3&gt;

&lt;p&gt;Sort the output in descending order by total income.&lt;/p&gt;

&lt;p&gt;Now the output data is different from the previously filtered collection.&lt;/p&gt;

&lt;p&gt;Because the output data now represents the result of your aggregation, which answers the question:&lt;br&gt;
&lt;strong&gt;What are the payment methods that bring in the most revenue?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In such cases, it makes sense to opt for a visual MongoDB &lt;strong&gt;GUI tool&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Chart Based on Aggregation Output
&lt;/h3&gt;

&lt;p&gt;The aggregation step is now complete; the result can be opened in Charts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2echxq99h2rnl99lni28.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2echxq99h2rnl99lni28.webp" alt="Pie chart created from the aggregation result." width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If chart detection works for this dataset, it will automatically create the chart based on its output structure. A pie chart would be an excellent choice here as it highlights the distribution of revenue across the different payment types.&lt;/p&gt;

&lt;p&gt;As you can see, the information is now more easily comprehensible.&lt;/p&gt;

&lt;p&gt;It’s no longer necessary to review the aggregated results and compare each line against others manually. The source of maximum income is apparent at first glance.&lt;/p&gt;

&lt;p&gt;This is one of the many benefits of &lt;strong&gt;integrating MongoDB queries, aggregations, and charts&lt;/strong&gt; into one workspace.&lt;/p&gt;

&lt;h2&gt;
  
  
  Combine Everything on One Dashboard
&lt;/h2&gt;

&lt;p&gt;A single chart is useful.&lt;/p&gt;

&lt;p&gt;But the dashboard offers the whole story.&lt;/p&gt;

&lt;p&gt;When you have already built charts using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a raw collection&lt;/li&gt;
&lt;li&gt;a filtered query&lt;/li&gt;
&lt;li&gt;an aggregation pipeline&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then you can combine them into a single dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq6tr39q4q6mepyscw1ik.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq6tr39q4q6mepyscw1ik.webp" alt="Dashboard with multiple MongoDB charts for payment analysis." width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It means that you are no longer analyzing individual parts of the information.&lt;br&gt;
Instead, you gain a holistic understanding of the data as a whole.&lt;/p&gt;

&lt;p&gt;This approach is much more similar to what a team would actually do when they:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;analyze trends&lt;/li&gt;
&lt;li&gt;compare values&lt;/li&gt;
&lt;li&gt;evaluate the results rapidly&lt;/li&gt;
&lt;li&gt;discuss them internally&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Moreover, as long as the chart remains linked to the underlying query or aggregation, you can still modify its structure if needed.&lt;/p&gt;

&lt;p&gt;In other words, the dashboard stops being a passive report and turns into an interactive database view.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Importance of MongoDB Visualization for Documentation
&lt;/h2&gt;

&lt;p&gt;Most companies view &lt;a href="https://visualeaf.com/docs/chart-builder" rel="noopener noreferrer"&gt;&lt;strong&gt;MongoDB documentation&lt;/strong&gt;&lt;/a&gt; as only about schemas or fields.&lt;/p&gt;

&lt;p&gt;However, documenting does not always have to mean annotating your data.&lt;/p&gt;

&lt;p&gt;Graphical representation of any kind provides documentation of what is going on in the database in an entirely visual form. Graphs allow identifying trends, making comparisons, analyzing distributions, as well as showing business insights and tendencies that cannot be conveyed through documents alone.&lt;/p&gt;

&lt;p&gt;Therefore, if you create graphs and dashboards using any type of &lt;strong&gt;MongoDB viewer&lt;/strong&gt; or &lt;strong&gt;MongoDB GUI&lt;/strong&gt;, you do more than just explore your data. You also create an additional level of documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The data stored in a MongoDB database is invaluable. However, it does not always make sense.&lt;/p&gt;

&lt;p&gt;A collection might have all the information you need, but in a format that you cannot decipher easily.&lt;/p&gt;

&lt;p&gt;Using a collection to create visual MongoDB queries, aggregating your findings, and designing a dashboard with different charts allows you to convert raw information into more meaningful content.&lt;/p&gt;

&lt;p&gt;It eliminates any guesswork about your data.&lt;br&gt;
Now, you can clearly visualize your findings.&lt;/p&gt;

&lt;p&gt;For those who wish to test out this process themselves, it is possible by using the &lt;a href="https://visualeaf.com/download" rel="noopener noreferrer"&gt;VisuaLeaf platform&lt;/a&gt; to discover the benefits of a data visualization tool for managing charts, queries, dashboards, and more informative MongoDB documentation.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>charts</category>
      <category>database</category>
      <category>analytics</category>
    </item>
    <item>
      <title>That's great!</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Mon, 20 Apr 2026 15:35:50 +0000</pubDate>
      <link>https://forem.com/visualeaf/thats-great-l2d</link>
      <guid>https://forem.com/visualeaf/thats-great-l2d</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/roxana_haidiner/visualeaf-as-a-studio-3t-alternative-59p" class="crayons-story__hidden-navigation-link"&gt;Faster MongoDB Alternative for Studio 3T in 2026&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/roxana_haidiner" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2224346%2Ff71cca7a-b282-4793-a3ae-b04d89957d47.png" alt="roxana_haidiner profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/roxana_haidiner" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Roxana-Maria Haidiner
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Roxana-Maria Haidiner
                
              
              &lt;div id="story-author-preview-content-3527556" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/roxana_haidiner" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2224346%2Ff71cca7a-b282-4793-a3ae-b04d89957d47.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Roxana-Maria Haidiner&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/roxana_haidiner/visualeaf-as-a-studio-3t-alternative-59p" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 20&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/roxana_haidiner/visualeaf-as-a-studio-3t-alternative-59p" id="article-link-3527556"&gt;
          Faster MongoDB Alternative for Studio 3T in 2026
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/mongodb"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;mongodb&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/nosql"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;nosql&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/database"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;database&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/compass"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;compass&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/roxana_haidiner/visualeaf-as-a-studio-3t-alternative-59p" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;4&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/roxana_haidiner/visualeaf-as-a-studio-3t-alternative-59p#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            6 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Compass Alternative | VisuaLeaf MongoDB GUI</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Thu, 16 Apr 2026 14:42:23 +0000</pubDate>
      <link>https://forem.com/visualeaf/visualeaf-as-a-mongodb-compass-alternative-blm</link>
      <guid>https://forem.com/visualeaf/visualeaf-as-a-mongodb-compass-alternative-blm</guid>
      <description>&lt;p&gt;If you spend some time working with MongoDB, you will inevitably reach a point where collection browsing is no longer enough.&lt;/p&gt;

&lt;p&gt;At first, everything is fine. You connect, open your collections, run your queries, and look at your data. But as your data grows, so does your need for more control, more clarity, and something faster.&lt;/p&gt;

&lt;p&gt;And so, you start looking for a MongoDB Compass alternative. Not because Compass is bad, but because you need something more than just a browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Makes a Great MongoDB GUI?
&lt;/h2&gt;

&lt;p&gt;A great MongoDB GUI is not just one that connects to your database. It’s one that actually helps you work with your data as things get more complex.&lt;/p&gt;

&lt;p&gt;A few things start to matter:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature area&lt;/th&gt;
&lt;th&gt;Why it matters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Querying experience&lt;/td&gt;
&lt;td&gt;You should be able to query data in a way that feels natural&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Aggregation support&lt;/td&gt;
&lt;td&gt;Pipelines can get hard to build and follow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Schema visibility&lt;/td&gt;
&lt;td&gt;MongoDB structure is not always easy to understand&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data exploration&lt;/td&gt;
&lt;td&gt;Browsing nested documents should feel simple&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Charts and dashboards&lt;/td&gt;
&lt;td&gt;Visual results are easier to understand and share&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Work across environments&lt;/td&gt;
&lt;td&gt;Switch safely between local, staging, and production without mistakes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Compare and sync&lt;/td&gt;
&lt;td&gt;Understand differences between collections and keep data in sync&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance insights&lt;/td&gt;
&lt;td&gt;Spot slow queries and improve performance with better indexing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Automation&lt;/td&gt;
&lt;td&gt;Run exports, imports, and migrations without repeating manual steps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database management&lt;/td&gt;
&lt;td&gt;Indexes, JSON Schema, and other tools matter in real projects&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These are the things that separate a simple collection browser from a tool that actually supports your workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why VisuaLeaf Feels Like a Strong Alternative
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://visualeaf.com/" rel="noopener noreferrer"&gt;VisuaLeaf&lt;/a&gt; isn't just a place where you open collections. It’s built to give you a more visual way to work with your data, your queries, and how everything connects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Querying feels more flexible
&lt;/h3&gt;

&lt;p&gt;Not everyone works the same way.&lt;/p&gt;

&lt;p&gt;Some people prefer visual queries. Others prefer &lt;a href="https://visualeaf.com/features/mongo-shell/" rel="noopener noreferrer"&gt;working in a shell.&lt;/a&gt; And some come from SQL and want something familiar before switching fully to MongoDB.&lt;/p&gt;

&lt;p&gt;VisuaLeaf supports all of these. You can use a visual query builder, run commands in the MongoDB shell, or write SQL-style queries.&lt;/p&gt;

&lt;p&gt;That makes it easier to switch depending on what you need, without changing tools.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr9kj1ez023lkh776pd6.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr9kj1ez023lkh776pd6.webp" alt="Visual MongoDB query builder for faster query creation" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Aggregations are easier to follow
&lt;/h3&gt;

&lt;p&gt;Aggregation pipelines are powerful, but they can get messy quickly.&lt;/p&gt;

&lt;p&gt;After a few stages, it becomes harder to follow what’s happening, and you spend more time reading the pipeline than building it.&lt;/p&gt;

&lt;p&gt;VisuaLeaf helps by letting you &lt;a href="https://visualeaf.com/features/aggregation-pipeline/" rel="noopener noreferrer"&gt;build pipelines visually&lt;/a&gt;, add stages with drag and drop, and preview results step by step.&lt;/p&gt;

&lt;p&gt;This makes it much easier to understand what each stage is doing as you go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy6rfp8y04lendxb7rdih.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy6rfp8y04lendxb7rdih.webp" alt="Visual MongoDB aggregation pipeline builder" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Schema is easier to understand
&lt;/h3&gt;

&lt;p&gt;One of the hardest parts of working with MongoDB is &lt;a href="https://visualeaf.com/features/visual-schema/" rel="noopener noreferrer"&gt;understanding how the data is structured.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As projects grow, you need to see how collections relate, how fields are nested, and how everything connects. This becomes even more important when working with a database you didn’t design yourself.&lt;/p&gt;

&lt;p&gt;VisuaLeaf helps with this through its Schema Designer, where you can visualize collections, fields, and relationships instead of trying to piece everything together from raw documents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzb6aphdd7smj0pwodaog.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzb6aphdd7smj0pwodaog.webp" alt="Visual MongoDB schema designer" width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Exploring data is smoother
&lt;/h3&gt;

&lt;p&gt;Working with nested documents can quickly become confusing.&lt;/p&gt;

&lt;p&gt;You open a document, expand fields, switch collections… and after a few steps, it’s easy to lose track.&lt;/p&gt;

&lt;p&gt;VisuaLeaf makes this easier by offering a structured way to &lt;a href="https://visualeaf.com/blog/how-to-explore-and-work-with-mongodb-data-visually/" rel="noopener noreferrer"&gt;explore collections&lt;/a&gt;, with clear views of nested fields and faster navigation between data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzy65elmen3z1kdgut3hf.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzy65elmen3z1kdgut3hf.webp" alt="Visual MongoDB data explorer" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  It goes beyond simply displaying query results
&lt;/h3&gt;

&lt;p&gt;Most MongoDB tools stop at showing query results.&lt;/p&gt;

&lt;p&gt;VisuaLeaf goes further by letting you turn those results into &lt;a href="https://visualeaf.com/features/chart-builder/" rel="noopener noreferrer"&gt;charts and dashboards.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can quickly create visualizations from your queries, which makes it easier to spot patterns and explain results without exporting data to another tool.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhozbustjc5ynaqdodku1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhozbustjc5ynaqdodku1.png" alt="MongoDB charts and dashboards from query results" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Work safely across environments
&lt;/h3&gt;

&lt;p&gt;In real projects, you rarely work with just one database.&lt;/p&gt;

&lt;p&gt;You switch between local, staging, and production, and mistakes can happen easily.&lt;/p&gt;

&lt;p&gt;VisuaLeaf helps you &lt;a href="https://visualeaf.com/features/connection-manager/" rel="noopener noreferrer"&gt;organize connections clearly,&lt;/a&gt; so you always know where you are working and reduce the risk of running something in the wrong place.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz23nmxe3ayngdax91pv6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz23nmxe3ayngdax91pv6.png" alt="MongoDB connection manager for multiple databases" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Compare and sync collections
&lt;/h3&gt;

&lt;p&gt;As your data evolves, you often need to check what changed between environments.&lt;/p&gt;

&lt;p&gt;VisuaLeaf lets you &lt;a href="https://visualeaf.com/features/collection-compare/" rel="noopener noreferrer"&gt;compare collections&lt;/a&gt;, see differences, and decide what needs to be updated.&lt;/p&gt;

&lt;p&gt;This saves a lot of time compared to manually checking data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdcvmodrkddpa8tzwajh7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdcvmodrkddpa8tzwajh7.png" alt="MongoDB collection compare tool" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Improve performance with profiling
&lt;/h3&gt;

&lt;p&gt;At some point, performance becomes important.&lt;/p&gt;

&lt;p&gt;VisuaLeaf includes tools that &lt;a href="https://visualeaf.com/features/query-profiler/" rel="noopener noreferrer"&gt;help you spot slow queries&lt;/a&gt; and understand where improvements are needed.&lt;/p&gt;

&lt;p&gt;This makes it easier to optimize your database without guessing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automate tasks and migrations
&lt;/h3&gt;

&lt;p&gt;Many &lt;a href="https://visualeaf.com/features/task-manager/" rel="noopener noreferrer"&gt;database tasks&lt;/a&gt; are repetitive.&lt;/p&gt;

&lt;p&gt;Exports, imports, migrations — you end up doing the same things again and again.&lt;/p&gt;

&lt;p&gt;VisuaLeaf helps you manage these tasks so they can be repeated more easily, instead of doing everything manually each time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwzdq396zenuzmzg7zom.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwzdq396zenuzmzg7zom.webp" alt="MongoDB task manager for background operations" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  It also goes beyond the basics
&lt;/h3&gt;

&lt;p&gt;As your project grows, your needs change.&lt;/p&gt;

&lt;p&gt;You start &lt;a href="https://visualeaf.com/docs/index-management" rel="noopener noreferrer"&gt;working with indexes&lt;/a&gt;, validating schemas, and managing more complex setups.&lt;/p&gt;

&lt;p&gt;VisuaLeaf includes these as part of the workflow, making it more useful in real projects, not just simple data exploration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who VisuaLeaf Is Best For
&lt;/h2&gt;

&lt;p&gt;VisuaLeaf is a good fit for people who need something more than just a MongoDB browser.&lt;/p&gt;

&lt;p&gt;It works well for developers who want flexibility in how they query data, and for anyone who uses aggregation pipelines and wants a clearer way to build them.&lt;/p&gt;

&lt;p&gt;It’s also useful for teams or growing projects where understanding structure and managing data becomes more important.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;MongoDB Compass is a good starting point. But as your work becomes more complex, you may need something that gives you more clarity and a more visual way to work with your data.&lt;/p&gt;

&lt;p&gt;VisuaLeaf brings querying, aggregations, schema visualization, and data exploration together in one place, making everyday work easier to follow.&lt;/p&gt;

&lt;p&gt;If you want to try it, you can start with the &lt;a href="https://demo.visualeaf.com" rel="noopener noreferrer"&gt;demo playground&lt;/a&gt;, use the free Community Edition, or test the full features with a 14-day free trial.&lt;/p&gt;

&lt;p&gt;There are also &lt;a href="https://visualeaf.com/pricing/" rel="noopener noreferrer"&gt;Basic and Professional plans&lt;/a&gt;, depending on what you need.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>nosql</category>
      <category>javascript</category>
      <category>database</category>
    </item>
    <item>
      <title>A Faster Way to Build MongoDB Queries Visually</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Mon, 06 Apr 2026 11:31:06 +0000</pubDate>
      <link>https://forem.com/visualeaf/a-faster-way-to-build-mongodb-queries-visually-4b0p</link>
      <guid>https://forem.com/visualeaf/a-faster-way-to-build-mongodb-queries-visually-4b0p</guid>
      <description>&lt;p&gt;Working with MongoDB, I found myself stuck on the same issue: I knew exactly what I wanted to do, but I still found myself spending too much time typing out my query every single time.&lt;/p&gt;

&lt;p&gt;Not because my query was particularly complex, but because of all the little things I had to keep track of. Field names, operators, nested paths, and so on. Making sure my syntax was correct, tweaking something small. It was just too much for something I ended up doing so many times.&lt;/p&gt;

&lt;p&gt;I wanted to find a way to make my query faster and more visual. Something that would let me spend more time on my data and less time typing everything out again.&lt;/p&gt;

&lt;p&gt;This is one of the reasons I ended up creating &lt;a href="https://visualeaf.com/" rel="noopener noreferrer"&gt;VisuaLeaf&lt;/a&gt;, and I have to say that my &lt;strong&gt;Visual Query Builder&lt;/strong&gt; is probably one of my favorite features.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Query Builder Starts Where You Already Work
&lt;/h2&gt;

&lt;p&gt;One thing I wanted from the beginning was to avoid opening five different screens just to build one query.&lt;/p&gt;

&lt;p&gt;So in this platform, the Query Builder opens directly from the &lt;strong&gt;collection view&lt;/strong&gt;. You open a collection, start browsing documents, and from there you can switch into visual query building without breaking your flow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5opujcicukeeb7sfahk6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5opujcicukeeb7sfahk6.png" alt="Query visually without leaving the collection" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That may sound like a small detail, but it matters.&lt;/p&gt;

&lt;p&gt;Because most of the time, real work does not start with “I want to build a query.”&lt;br&gt;&lt;br&gt;
It starts with “I’m already in this collection, and I want to find something faster.”&lt;/p&gt;

&lt;h2&gt;
  
  
  I Didn’t Want Drag-and-Drop to Feel Like a Gimmick
&lt;/h2&gt;

&lt;p&gt;A lot of tools have some form of visual query building, but once the query becomes more realistic, the interface starts to feel limited.&lt;/p&gt;

&lt;p&gt;That is exactly what I did not want.&lt;/p&gt;

&lt;p&gt;So in VisuaLeaf, you can &lt;strong&gt;drag and drop fields into the Query Builder&lt;/strong&gt;, and more importantly, you can keep adding &lt;strong&gt;multiple operations&lt;/strong&gt; and combine multiple fields in the same visual filter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdd98ywl83uzwrnovt22c.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdd98ywl83uzwrnovt22c.webp" alt="Combine multiple fields in one filter." width="800" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That makes a real difference, because most useful queries are not about one field only.&lt;/p&gt;

&lt;p&gt;You usually want something more like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one field should be greater than a value&lt;/li&gt;
&lt;li&gt;another field should match something else&lt;/li&gt;
&lt;li&gt;maybe sort the results&lt;/li&gt;
&lt;li&gt;maybe include only certain fields&lt;/li&gt;
&lt;li&gt;maybe group conditions with AND / OR&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is where a visual builder should still feel useful, not only at demo level.&lt;/p&gt;

&lt;h2&gt;
  
  
  You Can Build Visually, but the Real Query Is Still There
&lt;/h2&gt;

&lt;p&gt;This was important to me too.&lt;/p&gt;

&lt;p&gt;I did not want the Query Builder to become a toy interface where you click around but never really see what is happening underneath.&lt;/p&gt;

&lt;p&gt;So while you build visually, the real MongoDB query is generated automatically.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg844e3itoq7fqnjz1bpa.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg844e3itoq7fqnjz1bpa.webp" alt="You can build visually, but the real query is still there" width="800" height="1047"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That means the feature helps both kinds of users:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if you are newer to MongoDB, you can understand the query better&lt;/li&gt;
&lt;li&gt;if you already know MongoDB, you can move faster without losing control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the visual side is not there to hide the real query.&lt;br&gt;&lt;br&gt;
It is there to help you get to it faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Just Describe What You Want and Let AI Build It
&lt;/h2&gt;

&lt;p&gt;Sometimes I do not want to drag fields one by one either.&lt;/p&gt;

&lt;p&gt;Sometimes I just want to say what I need and start from there.&lt;/p&gt;

&lt;p&gt;That's why I decided to build the AI Helper in Query Builder, especially since we live in a world filled with AI. You can describe the query in plain English, let VisuaLeaf generate it, and then refine it if needed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3eet2ewljd80qeyh7rl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3eet2ewljd80qeyh7rl.png" alt="Start from a prompt instead of a blank query." width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you are still learning MongoDB&lt;/li&gt;
&lt;li&gt;you want a quick starting point&lt;/li&gt;
&lt;li&gt;you are testing an idea&lt;/li&gt;
&lt;li&gt;you do not feel like writing the full structure from zero&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And honestly, this is not only for beginners. Even experienced users have moments when they just want a faster start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the Query Is Only Half of It
&lt;/h2&gt;

&lt;p&gt;A query tool is not really good if the result is still hard to read.&lt;/p&gt;

&lt;p&gt;That is why I cared a lot about how the output is displayed too.&lt;/p&gt;

&lt;p&gt;In VisuaLeaf, after running a query, you can inspect the same result in different ways depending on what you need.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tree View
&lt;/h3&gt;

&lt;p&gt;This is the one I use when I want to understand the structure of a document better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9lcbeg1pa1f7i51i9g3.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9lcbeg1pa1f7i51i9g3.webp" alt="Expand nested data more naturally." width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is easier for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;nested fields&lt;/li&gt;
&lt;li&gt;arrays&lt;/li&gt;
&lt;li&gt;objects inside objects&lt;/li&gt;
&lt;li&gt;quick exploration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also makes it easier to search inside fields and values while you browse.&lt;/p&gt;

&lt;h3&gt;
  
  
  Table View
&lt;/h3&gt;

&lt;p&gt;This is better when I want to compare multiple documents faster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdfypft8b6p4bulvsgoj0.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdfypft8b6p4bulvsgoj0.webp" alt="Scan records faster in columns." width="800" height="559"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can scan rows and columns much more easily, which helps when you are trying to spot patterns or compare values side by side.&lt;/p&gt;

&lt;h3&gt;
  
  
  BSON View
&lt;/h3&gt;

&lt;p&gt;This is useful when exact MongoDB types matter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5trl2y8z4qzlz23dgzm9.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5trl2y8z4qzlz23dgzm9.webp" alt="See exact MongoDB types clearly." width="800" height="563"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes you do not just want to see the value.&lt;br&gt;&lt;br&gt;
You also want to see the actual type clearly, like &lt;code&gt;ObjectId&lt;/code&gt;, &lt;code&gt;Date&lt;/code&gt;, or other BSON-specific values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Search Inside Results Saves More Time Than People Think
&lt;/h2&gt;

&lt;p&gt;This is one of those features that sounds small, but in daily work it matters a lot.&lt;/p&gt;

&lt;p&gt;Once the documents are loaded, I do not want to rebuild the query every time just to find one value on the screen.&lt;/p&gt;

&lt;p&gt;I want to search through the results directly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkrnl2usk86obhcvbqg8d.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkrnl2usk86obhcvbqg8d.webp" alt="Find values directly in the loaded results." width="800" height="547"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So if I already have the data in front of me, I can keep exploring it without constantly starting over.&lt;/p&gt;

&lt;h2&gt;
  
  
  Speed Was Non-Negotiable
&lt;/h2&gt;

&lt;p&gt;A query tool can look nice, but if it feels slow, the whole experience becomes frustrating.&lt;/p&gt;

&lt;p&gt;That is why performance mattered from the beginning.&lt;/p&gt;

&lt;p&gt;In my own use, I can load even &lt;strong&gt;50k documents in less than 2 seconds&lt;/strong&gt;, and that changes the whole feeling of the tool. It means I can test, inspect, adjust, and continue without constantly waiting.&lt;/p&gt;

&lt;p&gt;That speed matters even more when combined with the result views and the search inside results, because the workflow stays fluid instead of feeling heavy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fdiopjerm6cdld3ujuu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fdiopjerm6cdld3ujuu.png" alt="50k docs in less than 1 second" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  I Also Wanted It to Connect Better to Real Development
&lt;/h2&gt;

&lt;p&gt;Another thing I did not want was a tool that only helps visually, but stops being useful the moment you need actual code.&lt;/p&gt;

&lt;p&gt;So VisuaLeaf can also generate the query in different programming languages like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python, Java, C#&lt;/li&gt;
&lt;li&gt;JavaScript - Node.js&lt;/li&gt;
&lt;li&gt;Kotlin, PHP, Ruby
and others.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foh88mvar0xhkaazc5u5o.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foh88mvar0xhkaazc5u5o.webp" alt="generate the query in different programming languages" width="800" height="722"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That makes the Query Builder more than just a visual helper.&lt;br&gt;&lt;br&gt;
You can build the query, verify the result, and then move more easily toward implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I wanted in the end
&lt;/h2&gt;

&lt;p&gt;I didn't want to build another MongoDB tool that looked impressive in demos&lt;br&gt;
but felt clunky in real work. So I focused on what actually matters day-to-day. That meant:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;opening the Query Builder directly from the collection view&lt;/li&gt;
&lt;li&gt;dragging and dropping multiple fields&lt;/li&gt;
&lt;li&gt;adding multiple operations without feeling limited&lt;/li&gt;
&lt;li&gt;keeping the real query visible&lt;/li&gt;
&lt;li&gt;using AI when I want a faster start&lt;/li&gt;
&lt;li&gt;switching between Tree, Table, and BSON views&lt;/li&gt;
&lt;li&gt;searching through results directly&lt;/li&gt;
&lt;li&gt;keeping the tool fast even with large result sets&lt;/li&gt;
&lt;li&gt;making it easier to move from visual query building to real code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is the direction behind &lt;a href="https://visualeaf.com/features/visual-query-builder/" rel="noopener noreferrer"&gt;VisuaLeaf Query Builder.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, if you're tired of writing MongoDB queries from scratch every time, try &lt;a href="https://visualeaf.com/download" rel="noopener noreferrer"&gt;VisuaLeaf&lt;/a&gt; and see how a more visual workflow can make the whole process easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  External Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/docs/manual/tutorial/query-documents/" rel="noopener noreferrer"&gt;MongoDB Query Documents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/docs/manual/reference/mql/query-predicates/" rel="noopener noreferrer"&gt;MongoDB Query Predicates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.in/mongodb/query-operations" rel="noopener noreferrer"&gt;MongoDB Query Operations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>mongodb</category>
      <category>database</category>
      <category>nosql</category>
      <category>data</category>
    </item>
    <item>
      <title>MongoDB Shell with Visual Output: A Smarter Way to Run and Explore Queries</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Tue, 31 Mar 2026 05:04:09 +0000</pubDate>
      <link>https://forem.com/visualeaf/a-smarter-mongodb-shell-with-built-in-visual-output-24co</link>
      <guid>https://forem.com/visualeaf/a-smarter-mongodb-shell-with-built-in-visual-output-24co</guid>
      <description>&lt;p&gt;One of the quickest ways to interact with your data is using the MongoDB shell.&lt;/p&gt;

&lt;p&gt;You can write queries, perform aggregations, and even make updates all in one place.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;courses&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2f22lkug8pxsu2c5165.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2f22lkug8pxsu2c5165.webp" alt="MongoDB Shell" width="800" height="616"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;MongoDB shell in VisuaLeaf, with query editor and visual results displayed in the same workspace.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Quick, easy, and powerful.&lt;/p&gt;

&lt;p&gt;But in real life, there’s more to doing this than just writing queries.&lt;/p&gt;

&lt;p&gt;You need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;understand the results&lt;/li&gt;
&lt;li&gt;check if the data is correct&lt;/li&gt;
&lt;li&gt;fix small mistakes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And this is where experience can really come in handy.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Better Way to Write MongoDB Queries
&lt;/h2&gt;

&lt;p&gt;You can write MongoDB queries inside VisuaLeaf just as you normally do.&lt;/p&gt;

&lt;p&gt;At the same time, you get help as you type.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax Highlighting
&lt;/h3&gt;

&lt;p&gt;Reading queries is easier because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;keywords are highlighted&lt;/li&gt;
&lt;li&gt;fields and values are separated&lt;/li&gt;
&lt;li&gt;the structure is easier to follow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don’t need to “parse” all that in your head.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Formf2kjrp7i5tv4cqzet.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Formf2kjrp7i5tv4cqzet.webp" alt="Mongo Shell Syntax Highlighting" width="658" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Syntax highlighting makes MongoDB queries easier to read and understand.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Auto-Completion
&lt;/h3&gt;

&lt;p&gt;As you type, you get suggestions for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;collections&lt;/li&gt;
&lt;li&gt;fields&lt;/li&gt;
&lt;li&gt;operators&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This lets you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;type faster&lt;/li&gt;
&lt;li&gt;avoid typos&lt;/li&gt;
&lt;li&gt;make fewer mistakes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don’t need to guess field names; you can select them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpb4uz900ds0xn357n8vv.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpb4uz900ds0xn357n8vv.webp" alt="Mongo Shell Auto-Complete" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Auto-suggestions help you find fields and operators faster while writing queries.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Running Queries Is Only Half of the Work
&lt;/h2&gt;

&lt;p&gt;After running a query, the real work starts.&lt;/p&gt;

&lt;p&gt;You need to understand the result.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tree View - Explore Your Data Without Getting Lost
&lt;/h3&gt;

&lt;p&gt;If your data is nested:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;only expand the fields that you need&lt;/li&gt;
&lt;li&gt;go step by step&lt;/li&gt;
&lt;li&gt;do not scroll through everything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes complex data much easier to understand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy7oxxowz21t2un49zdxb.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy7oxxowz21t2un49zdxb.webp" alt="Mongo Shell Tree View" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tree view lets you explore nested data step by step without getting lost.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Table View - Quickly Scan Your Results
&lt;/h3&gt;

&lt;p&gt;If your data is just for validation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;each document becomes a row&lt;/li&gt;
&lt;li&gt;each field becomes a column&lt;/li&gt;
&lt;li&gt;makes it easy to compare values&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ta0646zs5819a7x2m0u.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ta0646zs5819a7x2m0u.webp" alt="Mongo Shell Table View" width="800" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Table view makes it easy to scan and compare data across multiple documents.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Fixing the Data Directly from the Results
&lt;/h2&gt;

&lt;p&gt;This is one of the most useful parts.  &lt;/p&gt;

&lt;p&gt;If you notice a small mistake in your data, you don’t need to write another query — you can fix it directly from the results.  &lt;/p&gt;

&lt;p&gt;For example, if you see: &lt;em&gt;*&lt;strong&gt;&lt;em&gt;AlexandYr&lt;/em&gt;&lt;/strong&gt;*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Instead of : &lt;em&gt;*&lt;strong&gt;&lt;em&gt;Alexander&lt;/em&gt;&lt;/strong&gt;*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can edit the data directly from the results, without writing an update query.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8kon9vgyyclssgy28iwl.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8kon9vgyyclssgy28iwl.webp" alt="Mongo Shell Edit Inline" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can edit data directly in the results without writing an update query.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  A More Natural Workflow
&lt;/h3&gt;

&lt;p&gt;In practice, this changes how you work.&lt;/p&gt;

&lt;p&gt;Instead of switching between multiple steps, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write a query&lt;/li&gt;
&lt;li&gt;Run it instantly&lt;/li&gt;
&lt;li&gt;Explore the results&lt;/li&gt;
&lt;li&gt;Notice an error&lt;/li&gt;
&lt;li&gt;Fix it directly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can do everything in the same place.&lt;/p&gt;

&lt;p&gt;You do not need to move around different parts of the tool to verify the data.&lt;/p&gt;

&lt;p&gt;Everything is connected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The MongoDB shell is already powerful.&lt;/p&gt;

&lt;p&gt;But to use it efficiently, you must think about more than just executing queries.&lt;/p&gt;

&lt;p&gt;With:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;better query writing support&lt;/li&gt;
&lt;li&gt;reduced typing errors&lt;/li&gt;
&lt;li&gt;better exploration of query results&lt;/li&gt;
&lt;li&gt;direct data editing capabilities&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;you can think less about the tool, and more about your data.&lt;/p&gt;

&lt;p&gt;You still get the speed of MongoDB queries.&lt;/p&gt;

&lt;p&gt;But you get better understanding while working with them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;The best way to understand the difference is to try it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://visualeaf.com/download" rel="noopener noreferrer"&gt;Download VisuaLeaf&lt;/a&gt; and run a few queries on your own data.&lt;br&gt;&lt;br&gt;
Explore the results, switch views, and make a quick edit -&amp;gt; all in one place.&lt;/p&gt;

&lt;p&gt;Once you experience it, it’s hard to go back to a plain shell.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>bash</category>
      <category>nosql</category>
      <category>database</category>
    </item>
    <item>
      <title>When To Use MongoDB's $elemMatch</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Thu, 26 Mar 2026 15:34:00 +0000</pubDate>
      <link>https://forem.com/visualeaf/when-to-use-mongodbs-elemmatch-3ll0</link>
      <guid>https://forem.com/visualeaf/when-to-use-mongodbs-elemmatch-3ll0</guid>
      <description>&lt;p&gt;You have an e-commerce database. You want to find all orders where a customer bought a laptop for more than $1000. Simple query, right?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;items.category&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;items.price&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Except this returns orders where the customer bought &lt;strong&gt;any laptop&lt;/strong&gt; AND &lt;strong&gt;any item over $1000&lt;/strong&gt; - even if the laptop itself cost $50.&lt;/p&gt;

&lt;p&gt;This is MongoDB's most common query mistake. Let's see why it happens and how to fix it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem: Array Query Logic
&lt;/h2&gt;

&lt;p&gt;Here's sample data from an e-commerce orders collection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MacBook Pro&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mouse&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Wireless Mouse&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Chromebook&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;monitor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;4K Display&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What you want:&lt;/strong&gt; Orders where someone bought a laptop costing more than $1000 (Alice's order only)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What this query returns:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;items.category&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;items.price&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; BOTH orders (incorrect)&lt;/p&gt;

&lt;p&gt;Why? Because MongoDB checks each condition independently:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the array contain ANY item with &lt;code&gt;category: "laptop"&lt;/code&gt;? → Alice (yes), Bob (yes)&lt;/li&gt;
&lt;li&gt;Does the array contain ANY item with &lt;code&gt;price &amp;gt; 1000&lt;/code&gt;? → Alice (yes), Bob (yes - monitor is $1500)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bob's order matches because it has a laptop AND an expensive item - even though they're different items.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkc29nlphneqhz4ku8fs5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkc29nlphneqhz4ku8fs5.png" alt=" " width="800" height="505"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix: $elemMatch
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;$elemMatch&lt;/code&gt; ensures &lt;strong&gt;all conditions match the SAME array element:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; Only Alice's order (correct)&lt;/p&gt;

&lt;p&gt;Now MongoDB requires a SINGLE item in the array to satisfy both conditions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi739y78kpt6xmaojutjh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi739y78kpt6xmaojutjh.png" alt=" " width="800" height="584"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The visual query builder makes the structure clear: conditions nested under &lt;code&gt;$elemMatch&lt;/code&gt; must all match the same array element.&lt;/p&gt;

&lt;h2&gt;
  
  
  When You Need $elemMatch
&lt;/h2&gt;

&lt;p&gt;The key question: &lt;strong&gt;Do all conditions need to match the SAME array element?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If yes → use &lt;code&gt;$elemMatch&lt;/code&gt;. If no → use regular dot notation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Multiple Conditions on Array of Objects
&lt;/h3&gt;

&lt;p&gt;Imagine you need to find users who have admin access specifically in the finance department. Without &lt;code&gt;$elemMatch&lt;/code&gt;, you'll match users who are admins anywhere AND have any role in finance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// WRONG - finds any user with admin role OR finance department&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;roles.role&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;roles.department&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;finance&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This matches Sarah, who is an admin in engineering AND an editor in finance - but she's not a finance admin. The conditions matched different array elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// CORRECT - finds users who are admin IN finance department&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;roles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;department&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;finance&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now both conditions must match the same role object. Sarah won't match because no single role has both &lt;code&gt;admin&lt;/code&gt; AND &lt;code&gt;finance&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Range Queries on Nested Arrays
&lt;/h3&gt;

&lt;p&gt;Product reviews are another classic case. You want products where Alice specifically gave 5 stars - not products with any Alice review and any 5-star review.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// WRONG - products with any review by Alice OR any 5-star review&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;reviews.author&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;reviews.rating&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This returns a product where Alice gave 3 stars but Bob gave 5 stars. The conditions matched different reviews.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// CORRECT - products where Alice gave 5 stars&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;reviews&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you only get products where Alice's specific review was 5 stars.&lt;/p&gt;

&lt;h3&gt;
  
  
  When $elemMatch is NOT Needed
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Array of primitives&lt;/strong&gt;: If the array contains simple values (strings, numbers), you can't have "multiple conditions on the same element" - there's only one value per element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Array of primitives - $elemMatch not needed&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;electronics&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;// Simple array membership&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Single condition&lt;/strong&gt;: If you only have one condition, it doesn't matter which array element matches.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Single condition on array - $elemMatch not needed&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;items.category&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;// Just checking if ANY item is a laptop&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This correctly finds all orders containing at least one laptop, regardless of other items.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Mistake 1: Over-Complicating Primitive Array Queries
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ERROR - $elemMatch requires an operator expression, not a direct value&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;electronics&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;// Fails: "electronics" is not an expression&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;// MongoDB expects: { $elemMatch: { &amp;lt;operator&amp;gt;: &amp;lt;value&amp;gt; } }&lt;/span&gt;
&lt;span class="c1"&gt;// Not: { $elemMatch: &amp;lt;value&amp;gt; }&lt;/span&gt;

&lt;span class="c1"&gt;// UNNECESSARILY COMPLEX - this works but is verbose&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$eq&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;electronics&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;// Valid but overkill&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// CORRECT - simple and direct&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;electronics&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;// MongoDB automatically checks array membership&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$elemMatch&lt;/code&gt; CAN be used with primitive arrays, but only when you need complex conditions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// $elemMatch is useful for primitive arrays with multiple conditions&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;$lt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;// Array element between 100-200&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// For simple equality, just use direct matching&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;electronics&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;// Much simpler&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mistake 2: Mixing $elemMatch with Top-Level Conditions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// WRONG - status is outside $elemMatch&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;items.status&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shipped&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;// Checks ANY item's status (incorrect)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// CORRECT - all array conditions inside $elemMatch&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shipped&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;// Same item must be shipped (correct)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6c5cpw8v6p04y6ptker3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6c5cpw8v6p04y6ptker3.png" alt=" " width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 3: Over-Using $elemMatch
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// UNNECESSARY - single condition doesn't need $elemMatch&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// SIMPLER&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;items.category&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;laptop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Use $elemMatch?&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Array of primitives, single condition&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tags: "mongodb"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Array of objects, single condition&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"items.category": "laptop"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Array of objects, multiple conditions, &lt;strong&gt;same element&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;items: { $elemMatch: { category: "laptop", price: { $gt: 1000 } } }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Array of objects, multiple conditions, &lt;strong&gt;any element&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"items.category": "laptop", "items.inStock": true&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The Takeaway
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;$elemMatch&lt;/code&gt; is essential when you need &lt;strong&gt;all conditions to match the SAME array element&lt;/strong&gt;. Without it, MongoDB checks conditions independently, which can return unexpected results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules of thumb:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Array of primitives → no &lt;code&gt;$elemMatch&lt;/code&gt; needed&lt;/li&gt;
&lt;li&gt;Array of objects, single condition → no &lt;code&gt;$elemMatch&lt;/code&gt; needed&lt;/li&gt;
&lt;li&gt;Array of objects, multiple conditions on same element → use &lt;code&gt;$elemMatch&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;VisuaLeaf&lt;/strong&gt; is a MongoDB GUI built for developers. The visual query builder makes complex queries like $elemMatch easier to understand and build correctly.&lt;/p&gt;

&lt;p&gt;Try it at &lt;a href="https://visualeaf.com" rel="noopener noreferrer"&gt;visualeaf.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Examples tested with MongoDB 8.0. Demo data generator script available in VisuaLeaf documentation.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources and References
&lt;/h2&gt;

&lt;p&gt;This article is based on MongoDB's official documentation and query behavior:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MongoDB $elemMatch Projection Operator&lt;/strong&gt;&lt;br&gt;
MongoDB Documentation&lt;br&gt;
&lt;a href="https://www.mongodb.com/docs/manual/reference/operator/projection/elemMatch/" rel="noopener noreferrer"&gt;https://www.mongodb.com/docs/manual/reference/operator/projection/elemMatch/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MongoDB $elemMatch Query Operator&lt;/strong&gt;&lt;br&gt;
MongoDB Documentation&lt;br&gt;
&lt;a href="https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/" rel="noopener noreferrer"&gt;https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Query an Array of Embedded Documents&lt;/strong&gt;&lt;br&gt;
MongoDB Documentation&lt;br&gt;
&lt;a href="https://www.mongodb.com/docs/manual/tutorial/query-array-of-documents/" rel="noopener noreferrer"&gt;https://www.mongodb.com/docs/manual/tutorial/query-array-of-documents/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MongoDB Query Operators&lt;/strong&gt;&lt;br&gt;
MongoDB Documentation&lt;br&gt;
&lt;a href="https://www.mongodb.com/docs/manual/reference/operator/query/" rel="noopener noreferrer"&gt;https://www.mongodb.com/docs/manual/reference/operator/query/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All query examples and behaviors described in this article are based on MongoDB 8.0 specifications and have been verified against the official MongoDB documentation.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Written by the VisuaLeaf team • Questions? &lt;a href="mailto:support@sozocode.com"&gt;support@sozocode.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>nosql</category>
      <category>javascript</category>
      <category>database</category>
    </item>
    <item>
      <title>How to Understand a MongoDB Schema | From Raw JSON to Diagrams</title>
      <dc:creator>VisuaLeaf</dc:creator>
      <pubDate>Wed, 25 Mar 2026 15:20:25 +0000</pubDate>
      <link>https://forem.com/visualeaf/how-to-understand-a-mongodb-schema-from-raw-json-to-diagrams-hm8</link>
      <guid>https://forem.com/visualeaf/how-to-understand-a-mongodb-schema-from-raw-json-to-diagrams-hm8</guid>
      <description>&lt;p&gt;When you work with MongoDB, everything feels simple… at the beginning.&lt;/p&gt;

&lt;p&gt;You open a collection, look at a few documents, and it all makes sense.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For example, here’s a single collection with a few documents.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn99e29bvk0vos2e5wab2.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn99e29bvk0vos2e5wab2.webp" alt="Raw JSON Document" width="631" height="643"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When you start, reading a few documents is enough to understand the data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Everything is in one place, and the structure is easy to follow.&lt;br&gt;
You don’t need anything else to understand your data.&lt;/p&gt;

&lt;h2&gt;
  
  
  When the database grows, things change
&lt;/h2&gt;

&lt;p&gt;At first, your &lt;strong&gt;''learningPlatform''&lt;/strong&gt; database might look like this:&lt;/p&gt;

&lt;p&gt;You have &lt;strong&gt;students, courses, and enrollments&lt;/strong&gt; connecting them.&lt;/p&gt;

&lt;p&gt;Nothing complicated. You can understand everything just by looking at it.&lt;/p&gt;

&lt;p&gt;But real projects don’t stay this small.&lt;/p&gt;

&lt;p&gt;As new features are added, the database grows with them.  &lt;/p&gt;

&lt;p&gt;Then the project grows.  &lt;/p&gt;

&lt;p&gt;You add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;lessons&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;quizzes&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;reviews&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;certificates&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;progress&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;subscriptions&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;instructors&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;categories&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwm1tmrwtw2ts44ivbkgj.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwm1tmrwtw2ts44ivbkgj.webp" alt="mongodb-database-side-bar" width="320" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As the number of collections grows, it becomes harder to understand how everything connects.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But now it’s not just one collection.&lt;/p&gt;

&lt;p&gt;You want to understand how everything fits together, but it takes time, and you’re always piecing things together in your head.&lt;/p&gt;

&lt;h3&gt;
  
  
  The problem is not the data
&lt;/h3&gt;

&lt;p&gt;If you only read documents, you are always looking at things from the lowest level.&lt;/p&gt;

&lt;p&gt;But your database is not a collection of documents.It’s a system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start by seeing the structure
&lt;/h2&gt;

&lt;p&gt;The first step is easy:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What does this database look like as a whole?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of opening collections one by one, you look at at them as a group.&lt;/p&gt;

&lt;p&gt;You immediately see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;which collections exist&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;which ones are important (&lt;code&gt;students&lt;/code&gt;, &lt;code&gt;courses&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;which ones connect data (&lt;code&gt;enrollments&lt;/code&gt;, &lt;code&gt;payments&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;which ones add more detail (&lt;code&gt;lessons&lt;/code&gt;, &lt;code&gt;quizzes&lt;/code&gt;, &lt;code&gt;reviews&lt;/code&gt;, &lt;code&gt;progress&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this, I used &lt;a href="https://visualeaf.com" rel="noopener noreferrer"&gt;VisuaLeaf &lt;/a&gt;to generate a visual diagram of the database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqq26qrlr7de02oe97hk6.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqq26qrlr7de02oe97hk6.webp" alt="Visual Diagram in VisuaLeaf" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A schema diagram gives you a clear overview of all collections and their structure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A diagram shows you a complete overview of all collections and how they are structured, not because it looks pretty, but because it shows the big picture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Then understand the connections
&lt;/h2&gt;

&lt;p&gt;Once you see the collections, the next question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do these pieces connect?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In a MongoDB database, relationships are not enforced like in SQL.&lt;/p&gt;

&lt;p&gt;They are just fields.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;studentId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;courseId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;lessonId&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But those fields tell a story.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a student enrolls in a course&lt;/li&gt;
&lt;li&gt;a course contains lessons&lt;/li&gt;
&lt;li&gt;a lesson can have a quiz&lt;/li&gt;
&lt;li&gt;a student leaves a review&lt;/li&gt;
&lt;li&gt;a student can earn a certificate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9m1zdxb4giiiz99f4t5.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9m1zdxb4giiiz99f4t5.webp" alt="Relationship in MongoDB Diagram" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Relationships become easier to understand when you focus on how collections connect.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you see this visually, it makes it much easier to follow.&lt;/p&gt;

&lt;p&gt;A diagram is not enough, it just shows you the structure.&lt;/p&gt;

&lt;p&gt;But it doesn’t show you how the data actually looks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Look at the data, not just the structure
&lt;/h2&gt;

&lt;p&gt;Open a collection like &lt;code&gt;progress&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezfyr31wf499bokk3owt.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezfyr31wf499bokk3owt.webp" alt="Look at the data, not just structure" width="800" height="758"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Real documents often include nested structures that are harder to follow in raw JSON.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You start to see something different now.&lt;/p&gt;

&lt;p&gt;Not only fields, but real data too:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;arrays (&lt;code&gt;completedLessons&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;nested objects (&lt;code&gt;completedAssignments&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;multiple values and formats&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where MongoDB becomes powerful.&lt;/p&gt;

&lt;p&gt;And also where it becomes harder to read.&lt;/p&gt;

&lt;p&gt;It’s easy to understand one document.&lt;/p&gt;

&lt;p&gt;It’s much harder to see the pattern across many of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Structure + Data = Understanding
&lt;/h2&gt;

&lt;p&gt;This is the main idea.&lt;/p&gt;

&lt;p&gt;To understand a MongoDB database, you need both:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;structure → how collections connect&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;data → how documents actually look like&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One without the other is not enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where VisuaLeaf fits in
&lt;/h2&gt;

&lt;p&gt;This is where &lt;a href="https://visualeaf.com" rel="noopener noreferrer"&gt;VisuaLeaf &lt;/a&gt;helps.&lt;/p&gt;

&lt;p&gt;Not by adding more complexity, but by making things easier to see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you see the structure as a diagram
&lt;/li&gt;
&lt;li&gt;you explore collections and their fields&lt;/li&gt;
&lt;li&gt;you look at real documents and patterns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of guessing how things connect, you can actually see it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting it all together
&lt;/h2&gt;

&lt;p&gt;Every MongoDB project reaches this point.&lt;/p&gt;

&lt;p&gt;At the beginning, reading a few documents is enough.&lt;/p&gt;

&lt;p&gt;Later, it isn’t.&lt;/p&gt;

&lt;p&gt;You don’t need more data.&lt;/p&gt;

&lt;p&gt;You need to see how everything is connected.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you want to go a step further and explore your data in more detail, you can read this guide:&lt;br&gt;
&lt;a href="https://visualeaf.com/blog/how-to-explore-and-work-with-mongodb-data-visually/" rel="noopener noreferrer"&gt;https://visualeaf.com/blog/how-to-explore-and-work-with-mongodb-data-visually/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>mongodb</category>
      <category>database</category>
    </item>
  </channel>
</rss>
