Database - bommezijn/Dating-Shreks GitHub Wiki

Written by Parvin.

Database

Let's talk about the database we use. Well, as you might know from reading all the other articles within this wiki, we use MongoDB.

MongoDB is a document-oriented database program. It uses Javascript like documents, so it is very lovely to use as you are writing js. It is used by a lot of big companies like Google, eBay, EA & Adobe. The choice wasn't very difficult as we didn't get to choose from any other database.

💡 Did you know? MongoDB's name comes from the word humongous which means: very, very big!

How do we use it?

We use MongoDB to store the data of our users. This data is stored inside the cluster user. The data below is an example of how a user could look like:

_id: 5ed65f74af9921691cfbf832
name: "Parvin"
movieChoice1: "The Lighthouse"
movieChoice2: "The Godfather"

_id: = This _id is automatically created by MongoDB. We connected this _id to sessions and used it as its secret. Because this _id is created randomly, no one can ever find out 🔒 .

name: = The name you give to yourself at the start. This name is stored inside the database.

movieChoice1/2: = This is the movie choice you make. It takes the value of the radio button inside of the HTML and pushes it to the database.

With this user, we can do many things. For example, you connect sessions to the user, and you can request a session. With this, you can find out what the user is currently on your website. With this data you can render the name of the person to the HTML and voila:

Your name (from the database) is rendered and can be put anywhere in the HTML!


Sources

The most popular database for modern apps. (z.d.). Geraadpleegd op 21 juni 2020, van https://www.mongodb.com

Wikipedia-bijdragers. (2020, 29 mei). MongoDB. Geraadpleegd op 21 juni 2020, van https://nl.wikipedia.org/wiki/MongoDB