Skip to content

Guide: MongoDB

Megu edited this page Mar 6, 2026 · 7 revisions

Important MongoDB information

You will be given a database user and password to use the MongoDB database.

Each of you must create an .env file if you want to use the database. It must contain the url having your username and password. In order to do this, copy and paste the .env.test's first line you have in the users module with your user and password AND CREATE A NEW FILE .env.

So then, the .env file has this format:

MONGODB_URI=mongodb+srv://USER:PASSWORD@yovien1a.lzculny.mongodb.net/?appName=yovien1a

With your user and password.

VERY IMPORTANT: the .env file should NOT be uploaded to github

This file extension is already in the gitignore. But please, the .env file with your credentials should NOT be in a pushed commit, in main, only in your local computer.

If you by accident create a .env.txt or something similar, that will be PUBLIC.

This are the credentials to store in the database, and as you may understand, uploading that is VERY dangerous.

Also, do NOT change the .env.test file, not only the test from users may fail, but also dont put your username and password there, CREATE THE .env FILE SEPARATELY. If you remove the NODE_ENV to test, it will upload the tests cases to the database and we do not want that.

Explanation of the current implementation:

  • In order to connect to MongoDB, a secret called MONGODB_URI is already established.
  • .env.test file has the connection for the test of GitHub Actions.
  • Right now, the /createuser creates a user having username, email, password, createdAt (time the user was added to the db, autoinserted).
  • The password is already hashed in user service using bcrypt.
  • The login does not work YET as it finds all logins successful.

Personally, I recommend you to have MongoDB Compass Desktop App installed. It must be open when you execute the code to connect to the database. Any information you find relevant to include in this guide, please lmk!

Clone this wiki locally