Posted on

by

in

MongoDB Atlas: An Overview and how to get started

Introduction

MongoDB Atlas is a cloud database fully managed and secured and can be deployed on different cloud providers such as Amazon, Azure or Google, and the likes of your choice. Prior to the introduction of cloud technologies, companies managed, deploys, and fine-tune their own databases at their own premises. This introduces several complexities in terms of maintenance and fine-tuning. The concept of Database as a Service was coined to resolve these complexities. In this Mongodb Atlas overview, I am going to show you how to provision your own MongoDB cluster and get started using this.

You can choose to install MongoDB as a standalone application just as I did in my previous post. I used Windows as my workstation if I want to manage the database myself and for situations where you are not connected to the internet. I personally will use MongoDB Atlas or MongoDB in the future Internet of Things (IoT) projects so watch out for that!

MongoDB IoT Tutorial Series Roadmap

This post is Part 2 of my MongoDB Database for IoT Developers Series where I would show you how to set up your own MongoDB Atlas server and start interacting and communicating with it.

The below list would tell you the different topics that we are going to discuss in this series.

  • Part 1 – What is MongoDB database and why do we need it in our IoT projects?
  • Part 2 – MongoDB Atlas: An Overview and how to get started
  • Part 3 – Create a REST API Server with Python, Flask, and MongoDB
  • Part 4 – Control your Arduino IoT projects with a MongoDB database
  • Part 5 – Control your Raspberry Pi IoT projects with a MongoDB database
  • Part 6 – Control your MicroPython IoT projects with a MongoDB database
  • Part 7 – Arduino Data Logger using MongoDB Database
  • Part 8 – Raspberry Pi Temperature Logger using MongoDB Database
  • Part 9 – MicroPython Sensor Logger using MongoDB Database

What is MongoDB?

MongoDB JSON Document

Part 1 of this tutorial series already gave you an introduction to MongoDB and if you are not familiar with this database then I highly suggest that you read it.

But for a quick recap, MongoDB is a NoSQL or ‘non-relational‘ database which stores its data in JSON-like Format.

As you can see from the image above record is represented in JSON Notation. It uses Documents and Collections instead of the traditional rows and columns in relational. These type of databases are ideal for large sets of data, especially for Internet of Things (IoT) projects which gathers data from different sensor reads.

Prerequisites

In order to continue with this post, you will need a Google or GitHub account that is fully authenticated with 2FA (2 – Factor Authentication).

Setting up MongoDB Atlas

The general steps are fairly documented by the MongoDB team in this link but I am going to put up the steps that I followed since the screenshot is a little bit dated.

Create an account

Go to this link to register for a MongoDB Atlas account. You can either fill in your personal information and your email and set your password or you can choose to use your Google account. I used my personal Google account to register so that it would take care of the authentication mechanism.

mongodb register signup

Create free MongoDB cluster

If this is the first time to sign up then you will first be requested to create your own MongoDB cluster.

You can either use the MongoDB CLI (Command Line Interface) or the MongoDB UI to do this. MongoDB UI is the web interface that you will be interacting with. I have used MongoDB UI in my case but learning how to do this in the CLI is a good skill to learn as well.

Once your registration is successful then it will ask you to create a cluster for your account. As you can see, MongoDB offers a Paid Tier and a Free Tier. You can select the Paid tier later once you have a running application that is ready to release your project. The cost is dependent on the amount of data or storage that you are gonna be using. We will just use the Free Tier in this blog. Click the Create button.

mongodb pricing

I picked the Azure and Asia – Hongkong deployment in the cluster creation. You may choose others depending on the region that is nearest to you. Set the cluster name section depending on what is appropriate for you. The provisioning might take some time so be patient while waiting.

mongodb create cluster region

Add Your Connection IP Address to Your IP Access List

It is important to secure your cluster so that it will not be accessed by other users by restricting the IP Addresses that can access your cluster.

You can add as many IP addresses to this list. To do this task, we just need to click the Database and then click the Connect button.

mongodb add IP whitelist

Then click the Add IP Address button from the prompt. This will add our current IP address to the list that is able to access our cluster. Wait for the message that the IP address is added.

mongodb add current ip address

If you click the Network Access link then you would see that your IP Address is now included in the list.

mongodb network access

Create a database user for your cluster

You need to create a user for your cluster and set the credentials accordingly. We will use this in connecting to our database. To do that, click the Connect button again.

MongoDB Create User

Take note of the user’s password that you have assigned as we will need it to connect to our cluster later.

How to create a database in MongoDB Atlas?

Let us try adding our own custom database to our new MongoDB Atlas cluster.

We will create our own database called people_db which will store documents about a person’s information in a collection named people. To do this, go to the Collections tab and click Add My Own Data button.

MongoDB Atlas Create Database

On the next screen, input the database name and the collection name as follow.

MongoDB Atlas People Database

If everything goes well then we should be able to see the following displayed on your screen.

MongoDB Atlas People Database Created

We have only created our own custom database at this point but we have not populated it with our own dataset. We will do this in the preceding sections.

Connect to your cluster

Once we have set up our cluster then it is time to connect to it using the GUI tool called the MongoDB Compass. Download the MongoDB compass from here and install it in your workstation.

Once you have successfully installed your MongoDB Compass then open it. We need to supply it with the connection string to connect to our cluster. To do that, click the Overview tab of your cluster and then click the Connect button again.

MongoDB Atlas Overview and Connect

After which, a popup screen would come up asking you to choose how you want to connect to your cluster and select MongoDB Compass.

MongoDB Atlas Connect To Cluster

Select the Connect using the MongoDB Compass link then copy the connection string. Make sure to replace the <password> field with the password of the user that we created earlier.

MongoDB Connection String

In your, MongoDB Compass paste the connection string and then click Connect.

MongoDB Compass to MongoDB Atlas Connection

If everything goes well then we should be able to connect to our cluster and view the database objects in it. We have a database named people_db with a collection named people.

MongoDB Compass Database List

How to add a single test document in MongoDB Atlas using MongoDB Compass?

In Part 1 of this series, we have created a JSON document that will describe one person. We will add the same person information as a document in our people collection.

{
  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 27,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "office",
      "number": "646 555-4567"
    }
  ],
  "children": [
      "Catherine",
      "Thomas",
      "Trevor"
  ],
  "spouse": null
}

Click the Add Data button and then Insert Document.

MongoDB Compass Insert Document

Next, in the Insert Document popup, enter the above JSON document then click Insert.

MongoDB Compass Insert Single Document

If everything goes well then you should be able to see the following document created inside our people collection under our people_db database.

MongoDB Compass Document

How to insert multiple test data in MongoDB Atlas using MongoDB Compass?

If you want to add multiple documents as test data using MongoDB Compass then you can generate a JSON file that will contain your test data.

I used the site https://mockaroo.com to generate my test dataset in JSON format by supplying the schema values.

Mockaroo

I set it to generate at least 50 random person information that I would be inserting into my people collection inside my people_db database. You can download the JSON file below as we will be needing it at the next steps.

[{"firstName":"Neysa","lastName":"Mereweather","isAlive":"false","age":68,"address":{"streetAddress":"7 Birchwood Park","city":"Albany","state":"New York","postalCode":"12255"},"phoneNumbers":[{"type":"Mobile","number":"214-312-6206"},{"type":"Mobile","number":"895-577-2001"}],"children":[],"spouse":"null"},{"firstName":"Robinett","lastName":"Valasek","isAlive":"false","age":30,"address":{"streetAddress":"176 Basil Pass","city":"Mesa","state":"Arizona","postalCode":"85215"},"phoneNumbers":[{"type":"Business","number":"445-392-8426"},{"type":"Mobile","number":"595-272-2339"}],"children":[],"spouse":"null"},{"firstName":"Dell","lastName":"Leehane","isAlive":"true","age":12,"address":{"streetAddress":"40186 Lotheville Point","city":"Fort Wayne","state":"Indiana","postalCode":"46867"},"phoneNumbers":[{"type":"Home","number":"774-159-5087"},{"type":"Business","number":"555-700-4810"}],"children":[],"spouse":"null"},{"firstName":"Devin","lastName":"Dunan","isAlive":"false","age":75,"address":{"streetAddress":"162 Amoth Plaza","city":"Milwaukee","state":"Wisconsin","postalCode":"53277"},"phoneNumbers":[{"type":"Mobile","number":"779-793-4644"},{"type":"Business","number":"709-751-6695"},{"type":"Home","number":"226-292-0881"}],"children":[],"spouse":"null"},{"firstName":"Maurise","lastName":"Petrelli","isAlive":"true","age":48,"address":{"streetAddress":"85073 Carberry Drive","city":"Albuquerque","state":"New Mexico","postalCode":"87105"},"phoneNumbers":[{"type":"Home","number":"301-712-6696"},{"type":"Mobile","number":"947-716-4020"}],"children":[],"spouse":"null"},{"firstName":"Lamont","lastName":"Moughton","isAlive":"true","age":92,"address":{"streetAddress":"0656 Caliangt Circle","city":"Kansas City","state":"Missouri","postalCode":"64125"},"phoneNumbers":[{"type":"Home","number":"970-521-8127"}],"children":[],"spouse":"null"},{"firstName":"Sofia","lastName":"Mendez","isAlive":"true","age":43,"address":{"streetAddress":"72099 Elka Trail","city":"Indianapolis","state":"Indiana","postalCode":"46254"},"phoneNumbers":[{"type":"Home","number":"698-703-2194"}],"children":[],"spouse":"married"},{"firstName":"Aleda","lastName":"Furley","isAlive":"true","age":10,"address":{"streetAddress":"38467 Ludington Circle","city":"Pittsburgh","state":"Pennsylvania","postalCode":"15261"},"phoneNumbers":[{"type":"Business","number":"698-586-5050"},{"type":"Mobile","number":"618-216-0411"},{"type":"Mobile","number":"323-994-9917"}],"children":[],"spouse":"null"},{"firstName":"Townsend","lastName":"De Launde","isAlive":"true","age":36,"address":{"streetAddress":"4208 Trailsway Crossing","city":"Cincinnati","state":"Ohio","postalCode":"45254"},"phoneNumbers":[{"type":"Business","number":"537-708-9614"}],"children":[],"spouse":"null"},{"firstName":"Kristo","lastName":"Seagrove","isAlive":"false","age":53,"address":{"streetAddress":"9282 Hooker Way","city":"Denver","state":"Colorado","postalCode":"80217"},"phoneNumbers":[{"type":"Mobile","number":"842-749-1039"}],"children":null,"spouse":"married"},{"firstName":"Phedra","lastName":"Padley","isAlive":"false","age":8,"address":{"streetAddress":"6 Oak Hill","city":"Stockton","state":"California","postalCode":"95219"},"phoneNumbers":[{"type":"Business","number":"886-326-7711"},{"type":"Home","number":"370-280-0153"}],"children":[],"spouse":"married"},{"firstName":"Janith","lastName":"Yonge","isAlive":"true","age":38,"address":{"streetAddress":"1824 Linden Point","city":"South Lake Tahoe","state":"California","postalCode":"96154"},"phoneNumbers":[{"type":"Home","number":"957-215-4653"}],"children":[],"spouse":"married"},{"firstName":"Suzann","lastName":"Lippitt","isAlive":"true","age":81,"address":{"streetAddress":"8071 Del Sol Junction","city":"Ogden","state":"Utah","postalCode":"84409"},"phoneNumbers":[{"type":"Home","number":"378-534-7944"},{"type":"Business","number":"534-472-0799"},{"type":"Home","number":"584-363-6189"}],"children":[],"spouse":"married"},{"firstName":"Bing","lastName":"Desseine","isAlive":"false","age":16,"address":{"streetAddress":"79010 Summit Avenue","city":"Houston","state":"Texas","postalCode":"77005"},"phoneNumbers":[{"type":"Home","number":"471-367-0077"},{"type":"Mobile","number":"443-834-5793"},{"type":"Home","number":"978-685-7144"}],"children":[],"spouse":"null"},{"firstName":"Jocelin","lastName":"Delacroux","isAlive":"false","age":33,"address":{"streetAddress":"92 Huxley Street","city":"Cincinnati","state":"Ohio","postalCode":"45223"},"phoneNumbers":[{"type":"Business","number":"224-673-7845"}],"children":[],"spouse":"married"},{"firstName":"Lemmie","lastName":"Tuxell","isAlive":"true","age":90,"address":{"streetAddress":"239 Esch Circle","city":"Denver","state":"Colorado","postalCode":"80228"},"phoneNumbers":[{"type":"Home","number":"749-554-8103"},{"type":"Mobile","number":"608-605-3447"}],"children":[],"spouse":"null"},{"firstName":"Teena","lastName":"Valeri","isAlive":"false","age":69,"address":{"streetAddress":"4472 Vidon Center","city":"Anderson","state":"Indiana","postalCode":"46015"},"phoneNumbers":[{"type":"Mobile","number":"299-328-3163"}],"children":[],"spouse":"null"},{"firstName":"Maude","lastName":"Freak","isAlive":"true","age":47,"address":{"streetAddress":"835 Farwell Terrace","city":"Pittsburgh","state":"Pennsylvania","postalCode":"15225"},"phoneNumbers":[{"type":"Mobile","number":"255-446-0070"},{"type":"Home","number":"981-143-5643"}],"children":null,"spouse":"married"},{"firstName":"Cristy","lastName":"Whiley","isAlive":"true","age":91,"address":{"streetAddress":"15172 Graedel Place","city":"El Paso","state":"Texas","postalCode":"88535"},"phoneNumbers":[{"type":"Business","number":"251-754-3745"},{"type":"Mobile","number":"724-553-2000"},{"type":"Home","number":"950-526-8508"}],"children":[],"spouse":"married"},{"firstName":"Hubie","lastName":"Martinot","isAlive":"false","age":16,"address":{"streetAddress":"281 Northwestern Point","city":"Sacramento","state":"California","postalCode":"94286"},"phoneNumbers":[{"type":"Business","number":"194-900-5100"}],"children":[],"spouse":"married"},{"firstName":"Irina","lastName":"MacNeill","isAlive":"false","age":5,"address":{"streetAddress":"04 Dennis Hill","city":"New York City","state":"New York","postalCode":"10260"},"phoneNumbers":[{"type":"Business","number":"865-510-7176"}],"children":[],"spouse":"null"},{"firstName":"Katlin","lastName":"Glaserman","isAlive":"false","age":12,"address":{"streetAddress":"02202 Michigan Alley","city":"Carol Stream","state":"Illinois","postalCode":"60351"},"phoneNumbers":[{"type":"Mobile","number":"744-611-3183"}],"children":null,"spouse":"married"},{"firstName":"Padraic","lastName":"Dunnion","isAlive":"false","age":62,"address":{"streetAddress":"0494 Clarendon Circle","city":"Salt Lake City","state":"Utah","postalCode":"84110"},"phoneNumbers":[{"type":"Business","number":"443-239-2567"}],"children":null,"spouse":"married"},{"firstName":"Annice","lastName":"Maple","isAlive":"true","age":28,"address":{"streetAddress":"013 Saint Paul Place","city":"San Antonio","state":"Texas","postalCode":"78240"},"phoneNumbers":[{"type":"Mobile","number":"913-668-0683"}],"children":[],"spouse":"null"},{"firstName":"Burl","lastName":"Edelman","isAlive":"false","age":54,"address":{"streetAddress":"102 Schmedeman Plaza","city":"Nashville","state":"Tennessee","postalCode":"37228"},"phoneNumbers":[{"type":"Business","number":"679-458-8174"}],"children":[],"spouse":"null"},{"firstName":"Gav","lastName":"Drane","isAlive":"true","age":37,"address":{"streetAddress":"928 Pine View Plaza","city":"Edmond","state":"Oklahoma","postalCode":"73034"},"phoneNumbers":[{"type":"Mobile","number":"703-961-9113"},{"type":"Home","number":"128-752-5726"},{"type":"Business","number":"800-431-1700"}],"children":[],"spouse":"null"},{"firstName":"Caldwell","lastName":"Jakuszewski","isAlive":"false","age":2,"address":{"streetAddress":"002 Melrose Street","city":"Edmond","state":"Oklahoma","postalCode":"73034"},"phoneNumbers":[{"type":"Home","number":"593-176-6127"}],"children":[],"spouse":"null"},{"firstName":"Mommy","lastName":"Kirley","isAlive":"true","age":11,"address":{"streetAddress":"93 Leroy Plaza","city":"Wichita","state":"Kansas","postalCode":"67260"},"phoneNumbers":[{"type":"Mobile","number":"148-104-5250"}],"children":[],"spouse":"married"},{"firstName":"Hyatt","lastName":"Glacken","isAlive":"true","age":2,"address":{"streetAddress":"0 Northview Street","city":"Erie","state":"Pennsylvania","postalCode":"16505"},"phoneNumbers":[{"type":"Home","number":"492-266-1754"},{"type":"Home","number":"239-486-7672"}],"children":[],"spouse":"married"},{"firstName":"Rita","lastName":"Mangan","isAlive":"false","age":12,"address":{"streetAddress":"11 Bartelt Drive","city":"Bakersfield","state":"California","postalCode":"93381"},"phoneNumbers":[{"type":"Home","number":"645-934-4345"}],"children":[],"spouse":"married"},{"firstName":"Anne-marie","lastName":"Dullard","isAlive":"true","age":2,"address":{"streetAddress":"29 Cottonwood Street","city":"Cincinnati","state":"Ohio","postalCode":"45213"},"phoneNumbers":[{"type":"Home","number":"284-552-0834"},{"type":"Mobile","number":"955-820-4035"}],"children":[],"spouse":"null"},{"firstName":"Jarid","lastName":"Gollard","isAlive":"true","age":100,"address":{"streetAddress":"762 Northfield Plaza","city":"Springfield","state":"Illinois","postalCode":"62794"},"phoneNumbers":[{"type":"Mobile","number":"693-292-4191"},{"type":"Business","number":"596-728-8005"},{"type":"Mobile","number":"254-898-1443"}],"children":[],"spouse":"married"},{"firstName":"Inness","lastName":"Penas","isAlive":"false","age":63,"address":{"streetAddress":"00 Havey Street","city":"Seattle","state":"Washington","postalCode":"98166"},"phoneNumbers":[{"type":"Business","number":"169-263-7901"},{"type":"Mobile","number":"873-819-3860"}],"children":[],"spouse":"married"},{"firstName":"Anetta","lastName":"Tofanelli","isAlive":"false","age":6,"address":{"streetAddress":"75 Ronald Regan Trail","city":"Jacksonville","state":"Florida","postalCode":"32230"},"phoneNumbers":[{"type":"Home","number":"188-934-1573"}],"children":[],"spouse":"null"},{"firstName":"Peyter","lastName":"Showen","isAlive":"true","age":89,"address":{"streetAddress":"229 Valley Edge Trail","city":"Houston","state":"Texas","postalCode":"77266"},"phoneNumbers":[{"type":"Mobile","number":"573-928-4300"},{"type":"Home","number":"296-258-3580"}],"children":[],"spouse":"null"},{"firstName":"Pauly","lastName":"Brabon","isAlive":"true","age":34,"address":{"streetAddress":"1597 Elka Street","city":"Las Vegas","state":"Nevada","postalCode":"89178"},"phoneNumbers":[{"type":"Mobile","number":"802-210-9054"},{"type":"Mobile","number":"670-696-3641"}],"children":[],"spouse":"null"},{"firstName":"Oliviero","lastName":"Squirrel","isAlive":"true","age":84,"address":{"streetAddress":"818 Annamark Junction","city":"Young America","state":"Minnesota","postalCode":"55573"},"phoneNumbers":[{"type":"Home","number":"703-691-1818"},{"type":"Home","number":"779-318-3139"},{"type":"Business","number":"408-373-9256"}],"children":[],"spouse":"married"},{"firstName":"Dora","lastName":"Peggrem","isAlive":"true","age":72,"address":{"streetAddress":"546 Maryland Avenue","city":"Raleigh","state":"North Carolina","postalCode":"27690"},"phoneNumbers":[{"type":"Home","number":"812-231-1126"},{"type":"Business","number":"289-187-5411"},{"type":"Home","number":"139-139-3038"}],"children":[],"spouse":"null"},{"firstName":"Sande","lastName":"Care","isAlive":"true","age":43,"address":{"streetAddress":"53609 Quincy Trail","city":"Brooklyn","state":"New York","postalCode":"11241"},"phoneNumbers":[{"type":"Business","number":"818-164-3367"}],"children":null,"spouse":"married"},{"firstName":"Binnie","lastName":"Lockner","isAlive":"false","age":41,"address":{"streetAddress":"96 Autumn Leaf Pass","city":"Mobile","state":"Alabama","postalCode":"36670"},"phoneNumbers":[{"type":"Home","number":"899-883-5082"},{"type":"Home","number":"845-428-5406"},{"type":"Mobile","number":"664-985-1050"}],"children":null,"spouse":"married"},{"firstName":"Garrott","lastName":"Baulk","isAlive":"false","age":8,"address":{"streetAddress":"3499 Fair Oaks Crossing","city":"Missoula","state":"Montana","postalCode":"59806"},"phoneNumbers":[{"type":"Mobile","number":"571-964-8063"},{"type":"Mobile","number":"251-837-0565"}],"children":[],"spouse":"married"},{"firstName":"Marieann","lastName":"M'Chirrie","isAlive":"false","age":74,"address":{"streetAddress":"0 Jay Center","city":"Spokane","state":"Washington","postalCode":"99220"},"phoneNumbers":[{"type":"Mobile","number":"520-399-8251"}],"children":[],"spouse":"null"},{"firstName":"Riva","lastName":"Huchot","isAlive":"false","age":51,"address":{"streetAddress":"5 Dennis Circle","city":"Bridgeport","state":"Connecticut","postalCode":"06606"},"phoneNumbers":[{"type":"Home","number":"144-178-1045"},{"type":"Mobile","number":"342-774-2982"}],"children":null,"spouse":"married"},{"firstName":"Halli","lastName":"Gallety","isAlive":"true","age":80,"address":{"streetAddress":"3 Center Way","city":"Gainesville","state":"Florida","postalCode":"32627"},"phoneNumbers":[{"type":"Business","number":"162-808-7059"}],"children":[],"spouse":"married"},{"firstName":"Bradly","lastName":"Tooth","isAlive":"true","age":8,"address":{"streetAddress":"65 Caliangt Parkway","city":"Boston","state":"Massachusetts","postalCode":"02109"},"phoneNumbers":[{"type":"Home","number":"412-563-9410"}],"children":[],"spouse":"null"},{"firstName":"Pen","lastName":"Keith","isAlive":"false","age":67,"address":{"streetAddress":"9691 Jackson Trail","city":"Topeka","state":"Kansas","postalCode":"66606"},"phoneNumbers":[{"type":"Mobile","number":"558-319-7786"},{"type":"Home","number":"168-574-2898"}],"children":[],"spouse":"null"},{"firstName":"Josiah","lastName":"Rizzini","isAlive":"true","age":42,"address":{"streetAddress":"40246 Sutherland Plaza","city":"Dallas","state":"Texas","postalCode":"75277"},"phoneNumbers":[{"type":"Home","number":"587-234-2523"}],"children":null,"spouse":"null"},{"firstName":"Bernetta","lastName":"Hobell","isAlive":"false","age":11,"address":{"streetAddress":"263 Vahlen Point","city":"Sandy","state":"Utah","postalCode":"84093"},"phoneNumbers":[{"type":"Home","number":"117-261-3626"},{"type":"Mobile","number":"386-416-5628"},{"type":"Mobile","number":"272-649-7080"}],"children":[],"spouse":"married"},{"firstName":"Kaia","lastName":"De Angelo","isAlive":"true","age":77,"address":{"streetAddress":"391 Lake View Crossing","city":"Newark","state":"New Jersey","postalCode":"07104"},"phoneNumbers":[{"type":"Business","number":"280-240-9104"},{"type":"Business","number":"543-149-0381"}],"children":null,"spouse":"null"},{"firstName":"Janenna","lastName":"Girardin","isAlive":"true","age":84,"address":{"streetAddress":"73447 Thompson Terrace","city":"Olympia","state":"Washington","postalCode":"98516"},"phoneNumbers":[{"type":"Home","number":"235-775-3934"},{"type":"Business","number":"366-587-5176"},{"type":"Mobile","number":"132-729-2273"}],"children":[],"spouse":"null"}]

Once we have our test datasets then we can import it on our MongoDB Compass tool by clicking the Add Data and Import JSON or CSV File.

MongoDB Compass Import JSON

If everything goes well during the import then we should now have a test data set for our people collection like below.

MongoDB Compass Adding Test Dataset

How to query our data in MongoDB Atlas using MongoDB Compass?

Now that we have our collection filled with sample test data then it is time to retrieve information from our datasets. We do this by “querying” our people collection for information by supplying fields that we want to filter it with. The following list of examples will give you some idea of how this is done.

Filter by Last Name

If you want to filter by the last name then we could filter it by supplying the following fields:

{lastName: "Dullard"}

Type the above query in the input text box and click Find. You will notice that there is only one record that has this last name.

MongoDB Filter By Last Name

Filter by Age

Let us say we wanted to filter for records that are greater than 50 years old then we could supply the following query.

{age: {$gt: 50}}

Type the above query in the input text box again to filter our records for documents whose age is greater than 50.

MongoDB Filter By Age

There are lots of filter operators which you can find in the MongoDB documentation here.

Final Thoughts

We now have successfully set up our cluster in our MongoDB Atlas and is now ready to begin using it as our database for our future Internet of Things (IoT) projects.

That’s it!

Happy Exploring!

If you like my post then please consider sharing this. Thanks!

14 responses to “MongoDB Atlas: An Overview and how to get started”

  1. ESP32 Keypad Database Security System – Design – donskytech.com

    […] in MongoDB Atlas. If you want to learn more and get started about MongoDB Atlas then click this post that I have written about […]

    1. Asaraful Avatar
      Asaraful

      How to connect esp32 to mongodb atlas
      For sensor data store in it.
      Please make a simple video for that.

      1. donsky Avatar
        donsky

        Hey, I do am planning a post about that. I have InfluxDB in the pipeline also once I get time finishing all the projects I am working on. Please stay tuned.
        Thanks for the support.
        Happy exploring!

  2. Build REST API Using Node.js, Express and MongoDB – donskytech.com

    […] can just setup your MongoDB cluster by following this post as we need this to store our keycodes. But I highly suggest that you work your way into these steps […]

  3. ESP32 Keypad Database Security System – Design – donskytech.com

    […] in MongoDB Atlas. If you want to learn more and get started with MongoDB Atlas then click this post that I have written about […]

  4. Keypad with a Database Security System using Raspberry Pi

    […] in MongoDB Atlas. If you want to learn more and get started with MongoDB Atlas then click this post that I have written about […]

  5. ESP32 Keypad Database Security System Code – donskytech.com

    […] If you had a hard time understanding that post then you can skip that part and just setup your own MongoDB Atlas cluster by following this post. […]

  6. Raspberry Pi RFID Door Lock System with Database

    […] Related Content: Install Node.js on WindowsMongoDB Atlas: An Overview and how to get started […]

  7. How to install MongoDB on Raspberry Pi? – donskytech.com

    […] Related Content: MongoDB Atlas: An Overview and how to get started […]

  8. MongoDB Database for IoT Developers Series – donskytech.com

    […] Part 2 – MongoDB Atlas: An Overview and how to get started […]

  9. Create a REST API Server with Python, Flask, and MongoDB

    […] Part 2 – MongoDB Atlas: An Overview and how to get started […]

  10. Control your Arduino IoT projects with a MongoDB database

    […] Part 2 – MongoDB Atlas: An Overview and How to get started […]

  11. Develop Custom IoT Web Application with MongoDB Database

    […] Part 2 – MongoDB Atlas: An Overview and How to get started […]

  12. Arduino Data Logger using MongoDB Database – donskytech.com

    […] Part 2 – MongoDB Atlas: An Overview and How to get started […]

Leave a Reply

Your email address will not be published. Required fields are marked *