Connecting Locally to MongoDB
You can run your Empirica experiment locally, whilst still connecting it to a cloud MongoDB database.

Via the settings file

As explained in the guide for deploying to MongoDB, you will need to add these elements to your settings file:
1
"galaxy.meteor.com": {
2
"env": {
3
"MONGO_URL": "mongodb+srv://<read&write username>:<read&write password>@<connection>/<database name>?retryWrites=true&w=majority",
4
"MONGO_OPLOG_URL": "mongodb+srv://<oplog username>:<oplog password>@<connection>/local"
5
}
6
},
Copied!
Fill in the <> parts with the appropriate elements.
Now you can run your app with:
1
meteor --settings <name of settings file>
Copied!
This might not always work for connecting locally to your MongoDB. The method below is more reliable.

Via the command line

According to your OS, follow the instructions below to connect to your MongoDB via the command line.
Mac, Linux, Windows with WSL
Windows without WSL
Run this command with the URI you have obtained but without the ?retryWrites=true&w=majority
1
MONGO_URL=<MongoDB URI> meteor
Copied!
Create a .bat file (e.g., start.bat). These files allow you to run multiple commands on Windows. Do not run commands you are not comfortable with or not convinced they are secure.
Make sure that you have *.bat in your .gitignore because this file will contain sensitive information (your access to the database) and you don't want it to be sent to your repository. Add the following commands to the file with the URI you have obtained but without the ?retryWrites=true&w=majority:
1
SET MONGO_URL=<MongoDB URI>
2
meteor
Copied!
Run the file in the command line (e.g., .\start.bat ).
Last modified 5mo ago