This git repository demonstrates how to use MongoLab on OpenShift using Node.
Once you've created the quickstart, you'll need to create a MongoLab account and add your authorization information to your Git repository. Making code changes will require you to set a public SSH key, and then to clone your new application Git repository onto your local machine. See the Getting Started page for more steps in this flow.
git add . git commit -m "my first commit" git push
The example code uses
mongodb://localhost:27017/test when the MONGOLAB_URI environment variable is not available. This is sufficient for testing locally with your own mongodb, but not for production.
Note: We find that configuring this value outside of the code (and not storing it in a repository) allows for maximum security and flexibility. However, there are repository-driven alternatives for configuring this environment variable that may meet your requirements. See how to create and use environment variables on the server for more information.
To configure your environment variable without placing credentials in a repository:
export MONGOLAB_URI=<db uri>where db uri is the mongodb URI you obtained in Step 2, with your database user credentials added.
echo $MONGOLAB_URIto confirm success. The value you added should be displayed at the console.