Create and connect MongoDB database
Create a MongoDB database
MongoDB can be set up locally or in the cloud. MongoDB Atlas allows users to create one free tier database cluster with the cloud provider of your choice. OGRRE depends on GCP for other cloud services, so if using Atlas, it likely makes the most sense to use GCP.
To create a project and your free cluster, see the MongoDB documentation. The documentation also provides instructions on how to create a database user and connect to your database. To connect your database to OGRRE, you will need to create a database user.
To connect to the database, you must also ensure that the IP address you want to connect from is added to the access list. In the case of OGRRE, the backend IP address must be added to this list to allow it to access and update the database records. For information on how to add an IP address, see here.
Initialize Database for OGRRE
teams
, users
, and roles
. Furthermore, there must be at least one team and one user associated with that team, as well as a list of roles that are specific to OGRRE. You can create these manually, or use the python script we have provided to create these documents for you. The script can be downloaded here. The script takes the following arguments:- team_name (-t): the initial team name [required]
- email (-e): email of the initial user [required]
- assigned_role (-a): The role for the user you are creating. If not provided, the user will be assigned the role of
sys_admin
which contains all system and team permissions [optional] - database_username (-t): Database username [required]
- database_password (-e): Database user password [required]
- database_connection (-e): Database connection string [required]
- database_name (-e): Database name [required]
Environment variables for OGRRE
.env
file.- DB_USERNAME: The username for the database user you created.
- DB_PASSWORD: The password for the database user you created.
- DB_CONNECTION: The cluster host name.
- DB_NAME: The name of the database inside your cluster that you would like to connect to.
mongodb+srv://<DB_USERNAME>:<DB_PASSWORD>@<DB_CONNECTION>.mongodb.net