<?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>DEV Community: Caleb Hernandez</title>
    <description>The latest articles on DEV Community by Caleb Hernandez (@calebcode).</description>
    <link>https://dev.to/calebcode</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F684575%2Ff8bee4bb-f454-4981-b018-8882e1f33977.jpg</url>
      <title>DEV Community: Caleb Hernandez</title>
      <link>https://dev.to/calebcode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/calebcode"/>
    <language>en</language>
    <item>
      <title>3 useful operators when querying MongoDB</title>
      <dc:creator>Caleb Hernandez</dc:creator>
      <pubDate>Thu, 12 Aug 2021 01:48:55 +0000</pubDate>
      <link>https://dev.to/calebcode/3-operadores-utiles-al-hacer-consultas-en-mongodb-3mf1</link>
      <guid>https://dev.to/calebcode/3-operadores-utiles-al-hacer-consultas-en-mongodb-3mf1</guid>
      <description>&lt;p&gt;Hey! I'm Caleb and this is my first post so I hope the information given about this great database will be of much use to you.&lt;/p&gt;

&lt;p&gt;We will use the ** Heroes ** collection in this example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.heroe.find( { clase: { $in: [ "A", "D" ] } });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example we tell it that from the hero collection it looks for the data that is A or D in class, that is, if it does not find data equal to A it will look for those that are equal to D and display them.&lt;/p&gt;

&lt;p&gt;The second operator that we will see is $ or, in mongodb you can make queries where you have 2 options, that is, you can find data that meets 2 things or 3 things you are looking for or there is data that compiles with only 1 of the things you are looking for then you can bring them and make your query more complex for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.heroe.find( { $or: [ { clase: "A" }, { nivel: 30} ] } );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example we tell you that from the hero collection, look for those whose class is equal to A or whose level is equal to 30, if it does not find one of them, it will show us the one that it did find.&lt;/p&gt;

&lt;p&gt;The next that we see is an operator that helps us to make a query a little more detailed and I will show you in the example highlighted below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.heroe.find( { clase: "A"},{ nombre: /^p/ } );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in the example we do the query and we tell it that the hero collection and in class it is equal to A but take a good look at the following, we are telling it that its data begins with py that is operator number 3 of this post, the / ^ / where you can put any letter or number and thus make a more detailed query that can be used for a self-completing type of car or to order your data when displaying them.&lt;/p&gt;

</description>
      <category>mongodb</category>
    </item>
  </channel>
</rss>
