📖
Empirica v1 Docs
  • Introduction
  • Getting Started
    • Setup
      • Windows WSL Instructions
    • Creating your experiment
    • Running your experiment
    • Updating your experiment
  • Guides
    • Tutorial: Your First Experiment
      • Part 1: Getting Started
      • Part 2: Configuring the Experiment
      • Part 3: Adding Social Information and New Factors
      • Part 4: Adding Chats
      • Part 5: Adding Bots
    • The Settings File
      • Specifying Login Details
      • Setting player ids via URL queries
      • Connecting Locally to MongoDB
    • The Admin Panel
    • Special Empirica Elements (and how to modify them)
    • Deploying Your Experiment
      • Database
      • Hosting
    • Managing the Data
    • Using Custom Collections
  • Conceptual Overview
    • Structure
    • Game Life Cycle
      • Customising when players submit stages
    • Concepts
    • Randomization & Batches
    • API
  • FAQ
    • I need help!
    • The Processes and Elements of an Empirica Experiment
    • Managing Players and Games
  • Community Demos
    • Guess The Correlation
    • Random Dot Motion
    • Room Assignment
  • Tips & Tricks
    • Helpful Linux Commands
    • Code Editors
  • Links
    • Empirica website
    • Twitter
    • GitHub
Powered by GitBook
On this page
  • Via the settings file
  • Via the command line

Was this helpful?

  1. Guides
  2. The Settings File

Connecting Locally to MongoDB

PreviousSetting player ids via URL queriesNextThe Admin Panel

Last updated 3 years ago

Was this helpful?

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

To do so, you need to .

Via the settings file

As explained in the , you will need to add these elements to your settings file:

    "galaxy.meteor.com": {
        "env": {
            "MONGO_URL": "mongodb+srv://<read&write username>:<read&write password>@<connection>/<database name>?retryWrites=true&w=majority",
            "MONGO_OPLOG_URL": "mongodb+srv://<oplog username>:<oplog password>@<connection>/local"
        }
    },

Fill in the <> parts with the appropriate elements.

Now you can run your app with:

meteor --settings <name of settings file>

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.

Run this command with the URI you have obtained but without the ?retryWrites=true&w=majority

MONGO_URL=<MongoDB URI> meteor

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:

SET MONGO_URL=<MongoDB URI>
meteor

Run the file in the command line (e.g., .\start.bat ).

create the database and obtain the URI
guide for deploying to MongoDB