Skip to content

Instantly share code, notes, and snippets.

@cheeyeo
Created July 22, 2013 14:38
Show Gist options
  • Save cheeyeo/6054320 to your computer and use it in GitHub Desktop.
Save cheeyeo/6054320 to your computer and use it in GitHub Desktop.
Connecting to MongoHQ using Elixir on Heroku
# uses the mongoex plugin
if System.get_env("MONGOHQ_URL") !== nil do
connection = URI.parse( System.get_env("MONGOHQ_URL") )
host = '#{connection.host}'
port = connection.port
userinfo = String.split( connection.userinfo, ":" )
username = Enum.at(userinfo,0)
password = Enum.at(userinfo,1)
pool = 4
database = binary_to_atom( String.replace(connection.path,"/","") )
Mongoex.Server.setup(address: host, port: port, database: database, pool: pool, username: username, password: password)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment