MongoDB
Due to the abstract nature of the data stored in the Record Books project, a NoSQL database was chosen to store user data and application data. MongoDB is a NoSQL database that stores data in flexible, JSON-like documents. The database is hosted on MongoDB Atlas, a cloud-based database service that provides a fully managed database platform.
An instance of MongoDB Atlas was created for the Record Books project and it is connected to the 4-H record Books service email. (Login information can be found in the internal service account document.) The database is hosted on the RecordBooks
cluster in the RecordBooks
database.
Connecting to MongoDB
The Record Books project uses the mongoose
npm package to connect to the MongoDB database. The connection string for the database is stored in the MONGODB_URI
environment variable. The connection string is in the following format:
mongodb+srv://<username>:<password>@<cluster>/<database>
The connection string can be found in the .env.local
file in the root of the project. The connection string is used to connect to the MongoDB database using the mongoose.connect()
method in the _db/mongodb.js
file. The connection string can also be found by logging into the MongoDB Atlas dashboard and navigating to the RecordBooksCluster
->Connect->Compass->Copy the connection string. Admin password can be found in the internal service account document.
The section does not show how to connect and use the database. See the Database section in Code Base for more information on how to interact with the database.
MongoDB Compass
MongoDB Compass is a graphical user interface for MongoDB that allows you to explore and interact with your data. We recommend using MongoDB Compass to view and manage the data in the Record Books database. You can download MongoDB Compass from the MongoDB website. You will need to use the connection string from the .env.local
file to connect to the database in MongoDB Compass.
Future Considerations
If OSU IT is not able to configure a Cosmos DB instance for the Record Books project, the database should be migrated to be hosted on Azure using MongoDB Atlas on Microsoft Azure. This option still leverages the MongoDB Atlas service, but hosts the database on Azure infrastructure. This would allow the Record Books project to continue using MongoDB as its database, while also meeting the requirements of hosting the database on Azure.