Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 2.97 KB

MongoDB_README.md

File metadata and controls

65 lines (43 loc) · 2.97 KB

Host MongoDB

You can host MongoDB yourself, but we recommend using MongoDB Atlas. They offer a free tier for light usage and make it easy to extend if needed.

Using MongoDB Atlas

  1. Follow the MongoDB Atlas Official Tutorial to create your account, first Project and first Cluster (M0 Cluster for free tier).

  2. Follow the connection guild to set security permission, then select Connect to your application > Drivers in step 1.

  1. Copy the connection string provided by MongoDB Atlas below in step 2. It should start with mongodb+srv://....

  1. Create two Databases under the Cluster:
    • bot: to store data about servers being served by the bot
      • Create two Collections named guild and user under this Database.
    • abandon: to store data about servers that are no longer being served, for example, when the bot is removed from a server, its data would be archived into this Database.
      • Create one Collection named guild_left under this Database.
  • The names of the Database and Collections can be anything you want, but remember to replace their names into .env file later.

Self Hosting

  1. Based on your OS, following the MongoDB Official Tutorial to download the MongoDB Community Edition. For example, if you run on macOS:
brew tap mongodb/brew
brew update
brew install mongodb-community@7.0
  1. Run MongoDB in local server.
# To run MongoDB (i.e. the mongod process) as a macOS service, run:
brew services start mongodb-community@7.0

# To verify that MongoDB is running
# It should show 'mongodb-community started'
brew services list

# To stop a mongod running as a macOS service, use the following command as needed:
brew services stop mongodb-community@7.0
  1. (Optional, but Recommended if you prefer to use GUI tool) Follow Tutorial, download and install MongoDB Compass GUI.

  2. Make sure that MongoDB is running, open MongoDB Compass GUI and make a new connection to localhost.

  1. Copy localhost URI as connection string (it should start with mongodb://localhost...) to .env file.

  2. Create two Databases:

    • bot: to store data about servers being served by the bot
      • Create two Collections named guild and user under this Database.
    • abandon: to store data about servers that are no longer being served, for example, when the bot is removed from a server, its data would be archived into this Database.
      • Create one Collection named guild_left under this Database.
  • The names of the Database and Collections can be anything you want, but remember to replace their names into .env file later.