The MONGOHQ_URL
in your code snippet comes from the shell environment. For example, in bash
you would add that to your ~/.bash_profile
:
export MONGOHQ_URL="mongodb://user:pass@server.mongohq.com:port_name/db_name"
... or include on your command line when starting the node app:
MONGOHQ_URL="mongodb://user:pass@server.mongohq.com:port_name/db_name" node app.js
Another common approach with Node.js is to use something like dotenv
, which will load environment variables from a .env
directory in your project.
And also, what is the default value of MONGOHQ_URL here?
There is no default; you need to define this if you want to connect to a MongoHQ instance.