1. Home
  2. Training Library
  3. DevOps
  4. Courses
  5. Building A Cloud Native Application

Create MongoDB Database and Collection

The course is part of this learning path

Building and Deploying a Cloud Native Application
course-steps 4 certification 1 lab-steps 6

Contents

keyboard_tab
Introduction
1
Introduction
PREVIEW3m 32s
Quick Demonstration
Architecture Review
5
Go API
9m 54s
Test and Validation
Summary
12
Review
1m 15s
play-arrow
Start course
Overview
DifficultyIntermediate
Duration51m
Students37

Description

Introduction

This training course is designed to help you master the skills of designing and building cloud native applications.

Observe first hand the end-to-end process of building a sample cloud native application using React, Go, MongoDB, and Docker. By taking this course you'll not only get to see firsthand the skills required to create a robust enterprise grade cloud native application, but you'll also be able to apply them yourself as all code and deployment assets are available for you to perform your own deployment:

https://github.com/cloudacademy/voteapp-frontend-react
https://github.com/cloudacademy/voteapp-api-go
https://github.com/cloudacademy/language-vote-app

Learning Objectives

What you'll learn:

  • Understand the basic principles of building cloud native applications
  • Understand the benefits of using React for frontend web development
  • Understand the benefits of using Go for backend api development
  • Understand the benefits of using MongoDB as a database system
  • And finally, you’ll learn how to package and run microservices as lightweight containers using Docker

Demonstration

This training course provides you with several hands on demonstrations where you will observe first hand how to

  • Build a React based web frontend
  • Build a Go based API
  • Deploy and configure a MongoDB database
  • Deploy the full end-to-end application to Docker running locally

Prerequisites

  • A basic understanding of web based software development
  • Previous exposure to containers and containerisation - in particular docker

Intended Audience

  • Anyone interested in learning how to architect cloud native applications
  • Anyone interested in using modern development tools such as React, Go, MongoDB and Docker
  • Anyone interested in containerisation
  • DevOps Practitioners

Transcript

- [Instructor] Okay, welcome back. In this lecture, I'll demonstrate how to create and populate the MongoDB database hosted in the running docker container. 

Starting off from the demo directory, I'll use the curl command to download the Mongo version 4.2.0 shell clone like so. Now that the download is finished, I'll list the contents of the current directory and here we can see the downloaded file. Next, I'll extract and uncompress the file using the following tar command. 

I'll navigate into the new directory, clear the terminal and then examine its contents using the tree command, looking for the Mongo client binary. OK, here it is. Let's now start it up like so. Excellent, that's connected successfully. We are now ready to create the database and populate it. I'll first clear the Mongo shell like so. I'll then enter the Mongo command: use langdb. This will now create the new database that the API is designed to work with. Next, I'll paste in the following three insert commands to create the three programming language documents into the languages collection. Okay, that has worked successfully. 

I can query for all collections within the current database, like so and then query for all documents in this collection by using the following command which will format the results for us: db dot languages dot find dot pretty. Here we can see that we indeed have a document for the Go programming language, another document for Java programming language and another document for the Node.js programming language. Our data looks good. Okay, the database is now set up and ready to be used. Let's exit the Mongo shell and then cd back into the demo directory and then clear the terminal. 

Next, I'll retest the API by executing the following curl requests. This time, we can see that the API has retrieved the languages document data out of the MongoDB database. We can then drill down further into the data by querying the API for a programming language by name. In this example, I will query the API for the Go programming language data, like so, and then again, this time for the Java programming language and then once more for the Node.js programming language. 

OK, everything looks good. We are now ready to perform a final four end-to-end test of our locally hosted cloud native application.

About the Author

Students11052
Labs28
Courses65
Learning paths15

Jeremy is the DevOps Content Lead at Cloud Academy where he specializes in developing technical training documentation for DevOps.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 20+ years. In recent times, Jeremy has been focused on DevOps, Cloud, Security, and Machine Learning.

Jeremy holds professional certifications for both the AWS and GCP cloud platforms.
 

Covered Topics