MongoDB Test Application
Published: 2022-01-12 18:13:28

[Instructions]: # (To submit to the MongoDB Atlas Hackathon on DEV, please fill out all sections.)


### Overview of My Submission
[Note]: # (Please make sure the project links to the appropriate GitHub repository, and includes the [Apache-2 permissive license](https://www.apache.org/licenses/LICENSE-2.0)  and README.)

For the Hackathon I just want to try to implement a simple app, which connects to a MongoDB Atlas and allows to add records as well as see an overview of submitted data. In fact, whenever the page will be called, it will add a record and put the current number of records to the resulting page.

![Example result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ez51ioo2wrab1jc19wsd.png)
This is not supposed to be a great example, but it still hopefully can help people to create their own little applications connecting to MongoDB Atlas.
 


### Submission Category: 

[Note]: # (E-Commerce Creation, Prime Time, Action Star, Automation Innovation, or Choose Your Own Adventure)

[Note]: # (Prime Time)
Choose Your Own Adventure: Web App showing record count with MongoDB Atlas for adding and retrieving records


### Link to Code

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% github link_to_your_repo %}` to share a GitHub repository)

Link to source code: [Github](https://github.com/VeryUncommonCreativeUsername/MongoDBTestApplication)

### Additional Resources / Info

[Note]: # (Be sure to link to any open source projects that are using your workflow!)

[Note]: # (Screenshots/demo videos are encouraged!)

[Note]: # (Be sure to include the DEV usernames of your collaborators, if any. Prizes for winning projects with multiple collaborators will be sent to the person who posts this submission and they will distribute the prize evenly.)

[Note]: # ([Reminder]: # (Submissions are due on January 13th, 2022 @ 11:59 PM PT/2 AM ET on January 14th, 2022/6 AM UTC on January 14th, 2022).)

Note, that on MongoDB a free and shared cluster has been used. This is possibly the main difference to many other submissions for this Hackathon.

### Description

Here I will describe how to set up the project and try the app.

First we begin to create a database with MongoDB with a **Certificate** used to connect to it later. Because we want to add records, we need to create a **Database** "DevDatabase" and a **Collection** "Measurements". Then we need the **repository's** content and set up Node JS together with the needed modules.

If you use in the MongoDB portal "Connect" and then "Connect your Application" you should find what you need to change later in the code: The String shown has to be replaced in the code according to the example.
Also make sure to include the Certificate file _Certificate.pem_ in the project, which is not part of the repository and needed for authentication.
If you now run the "app.js" file, a local server will start and allow you to visit http://localhost:3000/. Whenever it is opened (e.g. also by refreshing) it will add a record to the database and then retrieve the records to count them for the number to be displayed.

This has been just to practice, but you still are welcome to leave some feedback or questions. Thank you for reading!